0

I have a DropDownList that lets the user change the themed stylesheet for a website. It does an autopostback to save the selection to my database. After this saves I want to force a complete page reload (not refresh). So the link to the stylesheet is rebuilt and the form is reset. Is this possible?

I have tried both:

Response.Redirect(Request.Url.AbsoluteUri)
Response.Redirect(Request.RawUrl)

And even tried JavaScript:

window.location.reload();
window.opener.location.href = window.opener.location.href;

but these just seem to cause a refresh. I seek a way that acts as if I clicked in the address bar and pressed [Enter].

UPDATE

This was a common case of not thinking things through thoroughly. I was attempting to do these actions through an iframe but the parent page was actually the one that set the theme stylesheet. I ended up getting this accomplished by simply:

If IsPostBack() Then
    Dim sb As New StringBuilder()
    sb.Append("<script type=""text/javascript"">")
    sb.Append("window.top.location.reload();")
    sb.Append("</script>")
    ClientScript.RegisterStartupScript(Me.GetType(), "reload", sb.ToString())
End If

Thanks everyone.

Steven B.
  • 8,962
  • 3
  • 24
  • 45
  • Add appropriate tags to your question. – rory.ap Jul 07 '16 at 16:49
  • @roryap `vb.net` is not an appropriate tag for a `vb.net` question? – Steven B. Jul 07 '16 at 16:49
  • Sure, but you seem to be having trouble with some web technology sub-set? ASP.NET possibly? You have sufficient rep to know how this works by now...I came here because I though it was a general vb.net question, and I don't know much about ASP.NET, so I was annoyed. That's what the purpose of tags are; if I had seen the appropriate tags, I would have just ignored the question. – rory.ap Jul 07 '16 at 16:51

2 Answers2

0

You might want to try to do something like cache bursting with version number, which is suggested in: Force browser to clear cache

Community
  • 1
  • 1
James Oravec
  • 19,579
  • 27
  • 94
  • 160
0

Maybe you can do as you are doing .... but also avoiding cache, adding this meta to your web page:

<meta http-equiv="cache-control" content="no-cache, must-revalidate, post-check=0, pre-check=0">
<meta http-equiv="pragma" content="no-cache">

And an old date

<meta http-equiv="expires" content="Sat, 31 Oct 2014 00:00:00 GMT"> 
Morcilla de Arroz
  • 2,104
  • 22
  • 29