当通过另一个 aspx 页面的 javascript 打开一个 aspx 时,不会触发 PageLoad 事件
我有一个包含 2 个 aspx 页面的 aspx 应用程序。使用 JavaScript 单击第一个 aspx 页面中的按钮即可打开第二个 aspx 页面。问题是,当打开第二个 aspx 页面时,其 Page_load 事件没有触发。仅当我刷新第二个页面时,才会触发第二个 aspx 页面的 page_load 事件。
请让我知道可能是什么问题以及如何触发 page_load 事件。
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下(从 window.open() 调用 aspx 页面),您必须在页面的 OnInit 事件中手动附加 Page_Load 事件:
参考: http://www.vbforums.com/showthread.php?t=249689
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:
reference: http://www.vbforums.com/showthread.php?t=249689
您是否使用 showModalDialog 打开页面?如果是这样,那么就是缓存问题。
如果是这样,有多种解决方法。有些人建议在 URL 的查询字符串中添加一个随机数或日期时间,这样它就不会被缓存。
就我个人而言,我喜欢这种方式。请参阅此处 http://msdn.microsoft .com/en-us/library/c4yy9w70.aspx 确保将其设置为 HttpCacheability.NoCache
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