Geeks With Blogs

News My Blog has been MOVED to
Michael Freidgeim's OLD Blog My Blog has been MOVED to

I've read Willem's Blog post Auto-refreshing ASP.NET web pages  and desided to post my helper function SetRefresh(Page page,int nDelaySec) that is similar to suggested by Willem's third method, but supports postbacks. It's important to keep values, entered by the user before refresh.

            public static void SetRefresh(Page  page,int nDelaySec)

            { // from


                  //NOTE: Often the __doPostBack function is inserted into your page by .NET. If not, put the code in manually, or add a dummy LinkButton and set it's style to be "display:none".

                  //     from


                  int nMilliSec=nDelaySec*1000;

                  StringBuilder sb = new StringBuilder();

                  sb.Append("setTimeout(myRefresh,"+ nMilliSec.ToString()+ ");");

                  sb.Append( @" function myRefresh()



                        } ");

                  page.RegisterClientScriptBlock("SetRefresh", JScript(sb.ToString()));


The function included in My JScriptHelper class

Posted on Monday, October 31, 2005 6:44 AM ASP.NET | Back to top

Comments on this post: SetRefresh Method for ASP.NET web pages to support postback.

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Michael Freidgeim | Powered by: