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,
[quoted text, click to view] "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]
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.
Thank you for the explanation! That has really cleared my view on the issue. I'll do what you suggested. [quoted text, click to view] "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] > >
Thank you for your help! [quoted text, click to view] "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.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. > > > > > > > > > >
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. [quoted text, click to view] "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.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. > > > > > > > > > >
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? [quoted text, click to view] "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.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. > > > > > > > > > >
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.
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.
Certainly! I'm currently trying to apply that new knowledge... thanks! [quoted text, click to view] "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. > > > >
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. [quoted text, click to view] "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. > > > >
And one more: Is I view the source of the page with the control, shouldn't I see the registered script? I can't see it. [quoted text, click to view] "Serendipity" wrote: > 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. > > > > > > > >
I said I will have questions... ;) I was looking at this ClientScriptManager.RegisterStartupScript function. I don't understand how this works. The MSDN article: http://msdn2.microsoft.com/en-us/library/z9h4dk8y(VS.80).aspx says "The script block added by the RegisterStartupScript method executes when the page finishes loading but before the page's OnLoad event is raised". What is the point of calling RegisterStartupScript from the Page_Load method, as in the example? Wouldn't that be too late? And how can I use it from a control, is it possible? Otherwise I have to have some HTML element clicked in order for polling to start. [quoted text, click to view] "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. > > > >
Hi Almog, As for the script callback polling, though you do not need it to do partial render, you'll still need it to poll the server-side processing status, don't you? Since the long-run task is running at server-side, and server-side can not actively notify client, client-side need to use script to postback(in background) to poll the result, that's why we need it here. Also, for the Page.ClientScript.RegisterStartupScript, it will output the registered script functions at the end of your page's <form> element.(rendered after other form elements have been rendered). You should be able to find them in the client browser's "View Source" file. Haven't you been able to find the function? Sincerely, Steven Cheng Microsoft MSDN Online Support Lead This posting is provided "AS IS" with no warranties, and confers no rights.
Don't see what you're looking for? Try a search.
|