[英]how can i use javascript pageLoad() event with each user control at one aspx page?
[英]PageLoad event is not fired when an aspx is opened through javascript of another aspx page
我有2個aspx頁面的aspx應用程序。 在第二個aspx頁面中,使用JavaScript單擊第一個aspx頁面中的按鈕即可打開。 問題是,當第二個aspx頁被打開時,其Page_load事件沒有觸發。 僅當刷新第二頁時,才會觸發第二個aspx頁的page_load事件。
請讓我知道可能是問題所在,以及如何觸發page_load事件。
提前致謝
在這種情況下(從window.open()調用aspx頁面),您必須在頁面的OnInit事件中手動附加Page_Load事件:
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
}
您是否正在使用showModalDialog打開頁面? 如果是這樣,那就是緩存問題。
如果是這樣,則有多個解決方案。 有人建議在URL的查詢字符串中添加一個隨機數或日期時間,以使其永遠不會被緩存。
就個人而言,我喜歡這種方式。請在此處參考http://msdn.microsoft.com/en-us/library/c4yy9w70.aspx確保將其設置為HttpCacheability.NoCache
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.