HighTechTalks DotNet Forums  

Updating a control with data on server event.

ASP.net Building Controls microsoft.public.dotnet.framework.aspnet.buildingcontrols


Discuss Updating a control with data on server event. in the ASP.net Building Controls forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Serendipity
 
Posts: n/a

Default Updating a control with data on server event. - 04-18-2007 , 01:32 PM






Hi, I'm new to ASP.NET, so please forgive me if my questions are sometimes
nonsensical.
I've read a few articals and I think I've got down the idea of "user action
on client -> postback -> server event raised and handled -> server renders
page and sends it back to the client" - right? But what I want to do is,
cause the control to be visibly updated, but not as a result of a user
action, but as a result of something that happens on the server (e.g.,
asynchronious action has returned with data). Can my control somehow tell the
server to render the page? Or is there another way to update control
appearance?
Thanks in advance,
Almog.

Reply With Quote
  #2  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-18-2007 , 04:51 PM






"Serendipity" <serendipity (AT) community (DOT) nospam> wrote

Quote:
Hi, I'm new to ASP.NET, so please forgive me if my questions are sometimes
nonsensical.
I've read a few articals and I think I've got down the idea of "user
action
on client -> postback -> server event raised and handled -> server renders
page and sends it back to the client" - right? But what I want to do is,
cause the control to be visibly updated, but not as a result of a user
action, but as a result of something that happens on the server (e.g.,
asynchronious action has returned with data). Can my control somehow tell
the
server to render the page? Or is there another way to update control
appearance?
The way you described it above it the way it works. You just left a piece
out:

"user action on client -> postback -> ASP.NET creates an instance of the
page -> the page creates instances of its controls -> server event raised
and handled -> server renders page and sends it back to the client ->
ASP.NET destroys the page and all controls on it"

So, your control can't tell the server anything, because no instance of your
control exists.

In these situations, one usually has the client make an asynchronous request
to the server. If you Google for "progress bar" and ASP.NET you'll find many
articles on this.
--

John Saunders [MVP]




Reply With Quote
  #3  
Old   
Steven Cheng[MSFT]
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-18-2007 , 11:03 PM



Hi Almog,

As for the "updating control ..." question you mentioned, I think it is a
typical asynchronous server-side processing and update client case, as John
has suggested, generally, you can let the server-side keep processing the
task(in a background thread) and the page will return the client
synchronously. After that, in client page, you can use script to constantly
post to the server and query the processing status, if finished, post back
the page and display final result.

Here are some former thread in newsgroup and tech articles in MSDN library
that discussing on similar topic:

http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8

#Reporting Task Progress With ASP.NET 2.0
http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/default.aspx

#How To: Submit and Poll for Long-Running Tasks
http://msdn2.microsoft.com/en-us/library/ms979200.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.











Reply With Quote
  #4  
Old   
Serendipity
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-19-2007 , 03:56 AM



Thank you for the explanation! That has really cleared my view on the issue.
I'll do what you suggested.

"John Saunders [MVP]" wrote:

Quote:
"Serendipity" <serendipity (AT) community (DOT) nospam> wrote in message
news:A6CAFE9D-A727-437E-890F-855A9EAD12F7 (AT) microsoft (DOT) com...
Hi, I'm new to ASP.NET, so please forgive me if my questions are sometimes
nonsensical.
I've read a few articals and I think I've got down the idea of "user
action
on client -> postback -> server event raised and handled -> server renders
page and sends it back to the client" - right? But what I want to do is,
cause the control to be visibly updated, but not as a result of a user
action, but as a result of something that happens on the server (e.g.,
asynchronious action has returned with data). Can my control somehow tell
the
server to render the page? Or is there another way to update control
appearance?

The way you described it above it the way it works. You just left a piece
out:

"user action on client -> postback -> ASP.NET creates an instance of the
page -> the page creates instances of its controls -> server event raised
and handled -> server renders page and sends it back to the client -
ASP.NET destroys the page and all controls on it"

So, your control can't tell the server anything, because no instance of your
control exists.

In these situations, one usually has the client make an asynchronous request
to the server. If you Google for "progress bar" and ASP.NET you'll find many
articles on this.
--

John Saunders [MVP]




Reply With Quote
  #5  
Old   
Serendipity
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-19-2007 , 03:58 AM



Thank you for your help!

"Steven Cheng[MSFT]" wrote:

Quote:
Hi Almog,

As for the "updating control ..." question you mentioned, I think it is a
typical asynchronous server-side processing and update client case, as John
has suggested, generally, you can let the server-side keep processing the
task(in a background thread) and the page will return the client
synchronously. After that, in client page, you can use script to constantly
post to the server and query the processing status, if finished, post back
the page and display final result.

Here are some former thread in newsgroup and tech articles in MSDN library
that discussing on similar topic:

http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8

#Reporting Task Progress With ASP.NET 2.0
http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/default.aspx

#How To: Submit and Poll for Long-Running Tasks
http://msdn2.microsoft.com/en-us/library/ms979200.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.












Reply With Quote
  #6  
Old   
Serendipity
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-21-2007 , 02:04 PM



Hi again,
I've read the articles, and they are indeed very helpful, but I still have a
few gaps that I don't know how to fill. I will describe the situation in more
detail: my control may be one of several controls on a page. The user can use
this control to poll for some data. I was planning to use a timer object. I
want the control fields to be updated with data when data is available. I
don't want the user to see a "wait..." page, I want the user to continue
using the same page.
So I have the asynchroneous opeartion running, and I can have a data store
that would tell me whether data is already available for my session, but I
still don't have an idea how to poll that data store.
Please help...
Almog.

"Steven Cheng[MSFT]" wrote:

Quote:
Hi Almog,

As for the "updating control ..." question you mentioned, I think it is a
typical asynchronous server-side processing and update client case, as John
has suggested, generally, you can let the server-side keep processing the
task(in a background thread) and the page will return the client
synchronously. After that, in client page, you can use script to constantly
post to the server and query the processing status, if finished, post back
the page and display final result.

Here are some former thread in newsgroup and tech articles in MSDN library
that discussing on similar topic:

http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8

#Reporting Task Progress With ASP.NET 2.0
http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/default.aspx

#How To: Submit and Poll for Long-Running Tasks
http://msdn2.microsoft.com/en-us/library/ms979200.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.












Reply With Quote
  #7  
Old   
Serendipity
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-22-2007 , 07:04 AM



One more question, and again please excuse my ignorance: how does data
binding work? Doesn't the client respond to changes in the data object on the
server?

"Steven Cheng[MSFT]" wrote:

Quote:
Hi Almog,

As for the "updating control ..." question you mentioned, I think it is a
typical asynchronous server-side processing and update client case, as John
has suggested, generally, you can let the server-side keep processing the
task(in a background thread) and the page will return the client
synchronously. After that, in client page, you can use script to constantly
post to the server and query the processing status, if finished, post back
the page and display final result.

Here are some former thread in newsgroup and tech articles in MSDN library
that discussing on similar topic:

http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/brow
se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8

#Reporting Task Progress With ASP.NET 2.0
http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/default.aspx

#How To: Submit and Poll for Long-Running Tasks
http://msdn2.microsoft.com/en-us/library/ms979200.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.












Reply With Quote
  #8  
Old   
Steven Cheng[MSFT]
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-23-2007 , 04:08 AM



Thanks for your Almog,

So you want the user still see the same page when the asychronous operation
executing at server-side and let the client-side constantly poll the
operation status without postback the page, correct?

To do this, you can simply use some AJAX script, here instead of involving
the new ASP.NET AJAX framework, I would suggest you have a look at the
ASP.NET 2.0's built-in client script callback feature. This feature can
help you generate client-side script that call a server-side method in your
page class(defined in codebehind or inline). Here are the related MSDN
reference and sample on using script callback:

#Implementing Client Callbacks Without Postbacks in ASP.NET Web Pages
http://msdn2.microsoft.com/en-us/library/ms178208(vs.80).aspx

#Client-Callback Implementation (C#) Example
http://msdn2.microsoft.com/en-us/library/ms178210(vs.80).aspx

#ICallbackEventHandler Interface
http://msdn2.microsoft.com/en-us/library/system.web.ui.icallbackeventhandler
..aspx

thus, you can define a server-side page method which will access the
certain data storage(such as Session) to check the operation status. And in
client-side, you can use "window.setInterval" to constantly invoke that
script callback function to poll for the status.

#JavaScript >> Window >>setInterval
http://www.devguru.com/technologies/javascript/10904.asp

#Using Timers in JavaScript - Sliding Around
http://www.devshed.com/c/a/JavaScript/Using-Timers-in-JavaScript/5/

Hope this helps further. If you still have any question, please feel free
to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #9  
Old   
Steven Cheng[MSFT]
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-25-2007 , 10:08 AM



Hi Almog,

Does the further information in my last reply helps you some? Please feel
free to post here if there is anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.





Reply With Quote
  #10  
Old   
Serendipity
 
Posts: n/a

Default Re: Updating a control with data on server event. - 04-26-2007 , 03:10 AM



Certainly!
I'm currently trying to apply that new knowledge... thanks!

"Steven Cheng[MSFT]" wrote:

Quote:
Hi Almog,

Does the further information in my last reply helps you some? Please feel
free to post here if there is anything else we can help.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.






Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.