最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

asp.net - PageLoad event is not fired when an aspx is opened through javascript of another aspx page - Stack Overflow

programmeradmin0浏览0评论

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
Add a ment  | 

2 Answers 2

Reset to default 5

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./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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论