Posts Tagged ‘server side page’

JavaScript ShowModalDialog + Aspx page_load event not fires

Wednesday, July 16th, 2008

I was using following code to show  Popup window

//opens a pop up window
function PopupWindow(url) {
mywindow =window.open( url, “Popupwindow”,
“location=1,status=0,scrollbars=1,width=800,
height=600,resizable=1,toolbar=0″ )

Above code was showing Popwindow then Requirement changed and we needed a Modal popup Window.  Then I found followin code which provides required functionality.

//opens a pop up window
function PopupWindow(url) {
var ie=document.all;
if (ie)
window.showModalDialog(url,”Window”,”status:no; help:no;
dialogWidth:1200px; dialogHeight:768px”);
else
{
var mywindow =window.open( url, “Popupwindow”,
“location=1,status=no,scrollbars=1,width=1200px,
height=768px,resizable=1,toolbar=0″ )
mywindow.focus();
}


I was using above code to show Audit and History of data for a specified field. This was not working 100% as When we open page in ModalWindow using ShowModalDialog it Caches all data. So the Page_Load Event of my .aspx page was not firing after 1st click for that specific field . As Page_Load event was not firing, I was unable to get the latest changes made by the user.  To See the latest changes made by user we were closing the browser and doing the whole process again i.e. open browser , login , search that record and see the history which was a pain.

To stop the page caching I am now using the page directiv

<%@ OutputCache Location=”None” %>

Above directive is not allowing page to cache anything so my problem is solved.

I can show the latest changes made by the user now. :)