views:

237

answers:

2

Hello everyone,

I am developing a webpart using VSTS 2008 + C# + .Net 3.5 + IIS 7.0 + ASP.Net. I want to refresh the whole page in my WebPart code, refresh I mean the same effect when user press F5 for browser.

I did not find a solution yet, any ideas?

thanks in advance, George

+4  A: 

Do it with javascript:

<a href="javascript:location.reload(true)">Refresh this page</a>

or if you want it automatically from the webpart, have it output code like this:

<script>
   window.location.reload(true);
</script>

(this assumes you're not in a frame)

Mikael Svenson
1. It will refresh only once? 2. What impact if I am in a frame? Frame you mean frameset or iframe?
George2
If you only want to refresh once, then you must check on "something" when it comes back so that you either don't output the code the second time, or skips it.If it's in a frame or iframe it will only refresh the content in that frame. If you want to refresh the main page or parent frame, you must get a reference to the parent object (parent.topFrame.window.location...)Perhaps you can expand your question to how you want this to actually work in a scenario?
Mikael Svenson
Thanks! Question answered!
George2
A: 

in a click event you could use:

Context.Response.Redirect(Context.Request.Url.GetLeftPart(UriPartial.Path));
Ren Hoek