Refreshing a page programatically

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
 
G

Guest

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

Simon Harvey

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top