OnClick事件未在ModalDialog上触发

时间:2010-07-16 14:32:03

标签: c# asp.net

我有一个模态对话框:

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);
    }
}

2 个答案:

答案 0 :(得分:0)

我记得以前看过这个问题,我认为这与缓存有关。在!IsPostBack

时,尝试将此添加到您的dialog.aspx page_load方法中
Response.AddHeader("Pragma", "no-cache")

停止浏览器缓存页面并重复使用

答案 1 :(得分:0)

您是否收到任何阻止POST的隐藏JavaScript错误?