无法在jquery对话框中单击asp.net按钮

Cod*_*nja 14 javascript c# asp.net jquery visual-studio-2010

我已经在线搜索过,并尝试了一些解决方案,但没有一个能为我工作.

我在div中有一个按钮.我在jquery对话框中显示div.按钮单击在jquery对话框中不起作用.

我的代码如下:

ASPX

    <div id='one'>
 <asp:LinkButton ID="ConfigureAlerts" OnClick="btnConfigureAlerts_Click" runat="server">Configure Alerts</asp:LinkButton>
</div>
<div id="ViewModalPopupDiv2">
        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <ContentTemplate>
            <asp:Panel ID="Panel2" runat="server" HorizontalAlign="left" ScrollBars="Auto">
            <asp:Button ID="btnGetLogs" runat="server" Text="SendAlerts" OnClick="btnSendAlertEmail_Click"/>
            </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
Run Code Online (Sandbox Code Playgroud)

jQuery的

function ViewModelPopup2() {
            $("#ViewModalPopupDiv2").dialog({
                scrollable: true,
                width: 800,
                modal: true
            });
        }
Run Code Online (Sandbox Code Playgroud)

aspx.cs

protected void btnSendAlertEmail_Click(object sender, EventArgs e)
        {

            // Code to send email

        }

protected void btnConfigureAlerts_Click(object sender, EventArgs e)
        {

        ScriptManager.RegisterStartupScript
                       (this, this.GetType(), "callScriptFunction", "ViewModelPopup2();", true);
        }
    }
Run Code Online (Sandbox Code Playgroud)

请让我知道我需要做什么,以触发服务器控制事件.

Gui*_*tos 23

我也有asp.net按钮和jQuery UI Dialog的这个问题.为了解决这个问题,你需要在你的ASPNET按钮的标签设置UseSubmitBehaviorfalse.

如果UseSubmitBehaviorattribute设置为true(这是默认值),该按钮将使用浏览器的提交机制(并且jQuery Dialog UI正在操作它),如果UseSubmitBehavior设置为false,该按钮将使用asp的客户端脚本.网络框架包括在页面中发布到表单.

所以你的HTML应该是这样的:

<div id='one'>
<asp:LinkButton ID="ConfigureAlerts" OnClick="btnConfigureAlerts_Click" runat="server">Configure Alerts</asp:LinkButton>
</div>
<div id="ViewModalPopupDiv2">
        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
            <ContentTemplate>
            <asp:Panel ID="Panel2" runat="server" HorizontalAlign="left" ScrollBars="Auto">
            <asp:Button ID="btnGetLogs" runat="server" Text="SendAlerts" OnClick="btnSendAlertEmail_Click" UseSubmitBehavior="false" />
            </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
Run Code Online (Sandbox Code Playgroud)

更多详细信息,请访问http://msdn.microsoft.com/library/system.web.ui.webcontrols.button.usesubmitbehavior.aspx