SetRefresh Method for ASP.NET web pages to support postback.

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 http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/msg/ffec2cc7c4836ed6?hl=en&

 

                  //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 http://www.codeproject.com/aspnet/OneTimeClickableButton.asp?msg=1185901

                  //window.Form1.submit();

                  int nMilliSec=nDelaySec*1000;

                  StringBuilder sb = new StringBuilder();

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

                  sb.Append( @" function myRefresh()

                        {

                         __doPostBack(document.forms[0].id,'');

                        } ");

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

            }

The function included in My JScriptHelper class

«October»
SunMonTueWedThuFriSat
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345