[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

Updating a control with data on server event.

Serendipity

4/18/2007 6:32:00 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.
13 Answers

John Saunders [MVP]

4/18/2007 9:52:00 PM

0

"Serendipity" <serendipity@community.nospam> wrote in message
news:A6CAFE9D-A727-437E-890F-855A9EAD12F7@microsoft.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]


stcheng

4/19/2007 4:04:00 AM

0

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.a...
se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8

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

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

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....
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/de....

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



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










Serendipity

4/19/2007 8:56:00 AM

0

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

"John Saunders [MVP]" wrote:

> "Serendipity" <serendipity@community.nospam> wrote in message
> news:A6CAFE9D-A727-437E-890F-855A9EAD12F7@microsoft.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]
>
>
>

Serendipity

4/19/2007 8:58:00 AM

0

Thank you for your help!

"Steven Cheng[MSFT]" wrote:

> 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.a...
> se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8
>
> #Reporting Task Progress With ASP.NET 2.0
> http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/de...
>
> #How To: Submit and Poll for Long-Running Tasks
> http://msdn2.microsoft.com/en-us/library/ms9...
>
> 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....
> 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/de....
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>
>
>
>
>
>
>
>

Serendipity

4/21/2007 7:04:00 PM

0

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:

> 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.a...
> se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8
>
> #Reporting Task Progress With ASP.NET 2.0
> http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/de...
>
> #How To: Submit and Poll for Long-Running Tasks
> http://msdn2.microsoft.com/en-us/library/ms9...
>
> 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....
> 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/de....
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>
>
>
>
>
>
>
>

Serendipity

4/22/2007 12:04:00 PM

0

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:

> 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.a...
> se_thread/thread/44302efa18ea9567/1619ca7b4000d2f8
>
> #Reporting Task Progress With ASP.NET 2.0
> http://msdn.microsoft.com/msdnmag/issues/06/09/CuttingEdge/de...
>
> #How To: Submit and Poll for Long-Running Tasks
> http://msdn2.microsoft.com/en-us/library/ms9...
>
> 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....
> 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/de....
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
>
>
>
>
>
>
>
>
>

stcheng

4/23/2007 9:08:00 AM

0

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/librar...(vs.80).aspx

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

#ICallbackEventHandler Interface
http://msdn2.microsoft.com/en-us/library/system.web.ui.icallbackev...
..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...

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

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.

stcheng

4/25/2007 3:09:00 PM

0

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.




Serendipity

4/26/2007 8:10:00 AM

0

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

"Steven Cheng[MSFT]" wrote:

> 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.
>
>
>
>
>

Serendipity

4/26/2007 12:34:00 PM

0

Here I am again with those questions...
I figured I actually don't have to poll for the server action, unless I want
to get partial data as it comes. When it ends, it will call the "OnSucceeded"
client script that I registered. Is that correct?
I still want to use setInterval to start off the server action. I'm not sure
it's possible, though.
If I understand correctly, the client script is registered with the page
containing the control. I can use registerStartupScript to call
setInterval(). The problem is I want to be able to change the interval, but
that would be impossible, wouldn't it? I can't change or unregister the
script?
Alternatively I was thinking to start a timer on the server, where I have
better control, and then I will use setInterval to poll the server for new
data.

"Steven Cheng[MSFT]" wrote:

> 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.
>
>
>
>
>