0

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?

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
George2
  • 44,761
  • 110
  • 317
  • 455

2 Answers2

4

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
  • 39,181
  • 7
  • 73
  • 79
  • 1. It will refresh only once? 2. What impact if I am in a frame? Frame you mean frameset or iframe? – George2 Dec 27 '09 at 09:40
  • 1
    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 Dec 27 '09 at 09:49
1

in a click event you could use:

Context.Response.Redirect(Context.Request.Url.GetLeftPart(UriPartial.Path));
Ren Hoek
  • 315
  • 2
  • 14