When using Modal Dialogs (esclusive focus windows) in Asp.Net with DataBase retrieved data, there are one small problem: data are loaded from db only the first time you open the window. After that, data is going to be loaded from the cache.
To solve this problem, we have to put into page load even onf the modal dialog page the following lines of code:
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.Now - New TimeSpan(1, 0, 0))
Response.Cache.SetLastModified(DateTime.Now)
Response.Cache.SetAllowResponseInBrowserHistory(False)
To open the window as modal dialog, use this javascript method:
hlkNewWindow.Attributes.Add("onclick", "javascript: window.showModalDialog('PageToOpen.aspx', null, 'status:no; dialogWidth:500px; dialogHeight:400px; dialogHide:true; help:no; scroll:no;')"
This example opens a modal dialog of 400x500 pixel, without status bar, buttons and scrolls with a click on the hlkNewWidow HyperLink.
1 comment:
Thanks very much for this explanation! I was stuck on this for hours before finding your solution.
Post a Comment