Force a complete reload of a page.

U

UJ

Is there any way I can have a page reload itself where it will completely
reload from scratch. I have a condition where a person click a button and
the easiest way to handle it would be to have the button do the DB stuff it
needs to do and then load the page from scratch - not post back.

I've tried putting in a server.transfer in the routine that does the button
click but it seems to get into an infinite loop.

TIA - Jeff.
 
M

manmit.walia

Hey Jeff,
Just create a javascript function to refresh the page. Then just add
that function to the asp.net button using
'Btn.Attributes.Add("onclick","your js function name")

Thanks
 
U

UJ

Actually I do a response.redirect to itself and it works great.

Thanks anyway.

Eliyahu Goldin said:
And the javascript will be

location.reload(true);

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

Hey Jeff,
Just create a javascript function to refresh the page. Then just add
that function to the asp.net button using
'Btn.Attributes.Add("onclick","your js function name")

Thanks
 
Joined
Aug 22, 2008
Messages
1
Reaction score
0
Actually I do a response.redirect to itself and it works great.

Excellent, I've been wrestling with viewstate for ages trying to get it to reload the values of text boxes from the DB, but this is a simple, quick and easy solution to all my problems!

Cheers :barresed:
 
Joined
Feb 27, 2009
Messages
1
Reaction score
0
Try this instead of Response.Redirect, It works perfectly well....

Response.AddHeader "Refresh", "0;URL=default.asp"

This will reload the page specified, if you want to use it to reload the same page after executing some scripting you can use a variable....

If PageStatus = "reload" Then
Response.AddHeader "Refresh", "0;URL=SamePage.asp"
PageStatus = ""
End If

If you are executing script on a different page, you can also pass the information and retreive it using the Querystring

Samepage.asp?PageStatus=reload

PageStatus = Request.QueryString("PageStatus")
If PageStatus = "reload" Then
Response.AddHeader "Refresh", "0;URL=SamePage.asp"
PageStatus = ""
End If

* Zero is the time before reloading....
* Do not forget to clear PageStatus otherwise you will be stuck in a loop

Enjoy
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top