Hello, Welcome to my blog. If you like feel free to refer others

Tuesday, 27 November 2012

window.showModalDialog Page Load not being executed everytime

Problem : Loading a page as a modal dialog box as window.showModalDialog("myurl.aspx"). The first time the modal dialog is poped up the page load event gets called. When i close it and call the same again, the Control does not come to the Page_Load(). Instead the page pops up with the previous values in all its controls. What we want is the Page_Load() to be triggered every time the modal dialog pops up.

Solution: First of all showModalDialog is an proprietary IE only feature its not supported by all browsers

Solution 1 :   You need to add a unique query string value to the URL that you are using to avoid IE showing the cached version. So generate a random number and append it to the URL e.g myurl.aspx?rnd=12237827348273. This should bust the cache and make a fresh request

Solution 2 : Turn caching of on the page by using @OutputCache directive 

<%@ OutputCache Duration="1" Location="None" VaryByParam="none" %>

Solution 3 :  Call----- Response.Cache.SetCacheability(HttpCacheability.NoCache);

Hope that will help you. Happy Learning...... :)

No comments:

Post a Comment