I have an aspx application with 2 aspx pages. Second aspx page will get opened on 开发者_运维问答click of a button in first aspx page using JavaScript. The problem is, when the second aspx page is getting opened, its Page_load event is not firing. Only when I refresh the second page, page_load event of second aspx page is fired.
Please let me know what might be the problem and what is to be done to fire the page_load event.
Thanks in Advance
In this case (calling the aspx page from window.open()) you have to attach the Page_Load event manually in the page's OnInit event:
override protected void OnInit(EventArgs e)
{
this.Load += new EventHandler(Page_Load);
base.OnInit(e);
}
protected void Page_Load(object sender, EventArgs e)
{
// your code here
}
reference: http://www.vbforums.com/showthread.php?t=249689
Are you opening the page with showModalDialog? if so, then it's the caching issue.
If so there are muliple work arounds. Some suggest to add a random number or datetime to the query string to the URL so that it does not get cached ever.
Personally, I like this way of doing it.Refer here http://msdn.microsoft.com/en-us/library/c4yy9w70.aspx Make sure you set it to HttpCacheability.NoCache
精彩评论