admin管理员组文章数量:1394125
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
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
Share Improve this question asked Jan 25, 2011 at 11:03 asdasd 652 gold badges3 silver badges9 bronze badges 2- I guess there is no issue in page. It is issue with browser cache. Clear your browser cache before opening second page, it should work. – hungryMind Commented Jan 25, 2011 at 11:12
- Thank you. Its cache problem. – asd Commented Jan 27, 2011 at 6:45
2 Answers
Reset to default 5In 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./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./en-us/library/c4yy9w70.aspx Make sure you set it to HttpCacheability.NoCache
本文标签:
版权声明:本文标题:asp.net - PageLoad event is not fired when an aspx is opened through javascript of another aspx page - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744773778a2624500.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论