Refreshing a page programatically

  • Thread starter Thread starter Simon Harvey
  • Start date Start date
S

Simon Harvey

HI all,

Does anyone know how I can make a page refresh itself programatically if a
given event is fired.

I thought there would be some method like doPostBack() or something but I
can't see anything like that

Thanks

All

Simon
 
Response.Redirect is used to direct the web page somewhere
Request.ServerVariable["SCRIPT_NAME"] is a Server Variable that holds the
path used to access the web page
eg /WebApplication1/WebForm1.aspx
the / Forces it to go to the root directory thus it will reload itself

Response.Redirect(Request.ServerVariables["SCRIPT_NAME"]);
return;
The above code forces a page to reloads itself. Just be careful where you
put it otherwise you will end up in a never ending loop ;)
As a general rule you should also put a return; right after the code so no
other code accidentally gets executed.

Hope this helps.
This posting is provided as is.
 
Hi there,

Thanks for your help.

One thing I'm wondering about what you suggest is if this approach to the
problem would result in the same type of refresh as a postback. For example,
what would happen with the viewstate?

Thanks again

Simon
 
Back
Top