2010-07-16 46 views
0

我有一個模態對話框:OnClick事件不是射擊ModalDialog

function ShowPopup() 
{ 
    window.showModalDialog('dialog.aspx', null, 'status:no;dialogWidth:950px;dialogHeight:150 px'); 
} 

那麼它叫後面的代碼

Page.ClientScript.RegisterStartupScript(this.GetType(), "popUpScript", "ShowPopup();", true); 

的dialog.aspx有兩個按鈕:

<asp:Button id="btn1" runat="server" Text="Button 1" OnClick="btn1_Click"></asp:Button> 
<asp:Button id="btn2" runat="server" Text="Button 2" OnClick="btn2_Click"></asp:Button> 

但是,後面的代碼中的Click事件永遠不會被解僱。

protected void Page_Load(object sender, EventArgs e) 
    { 
    } 

    protected void btn1_Click(object sender, System.EventArgs e) 
    { 
     Response.Redirect(url) 
    } 

    protected void btn2_Click(object sender, System.EventArgs e) 
    { 
     Response.Redirect(url); 
    } 
} 

回答

0

我記得以前看過這個問題,我認爲它與緩存有關。嘗試添加這對您的dialog.aspx的Page_Load方法的時候!的IsPostBack

Response.AddHeader("Pragma", "no-cache") 

要停止瀏覽器緩存的頁面,並在重新使用

+0

沒有運氣。仍然沒有擊中按鈕點擊事件。 – user234702 2010-07-16 17:13:20

+0

它甚至打到page_load?像rick建議的一樣,確保沒有js錯誤。確保頁面元素的aspx具有AutoEventWireup =「true」。同時仔細檢查並確保你沒有dialog.aspx的多個副本,並加載了錯誤的文件 – 2010-07-17 03:09:29

+0

.aspx上的AutoEventWireup設置爲true - 據我所知,沒有js錯誤。我確實快速查看了是否有一箇舊版本的dialog.aspx被加載,但我沒有。 – user234702 2010-07-19 12:32:45

0

您收到任何隱藏的JavaScript錯誤防止POST?