0

我正在使用带有 Asp.net Webforms 的 twitter 引导模式。

事件单击按钮btnSubmit后,模式消失。

如何保持模态活跃?

示例.aspx:

<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>    
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<asp:Button CssClass="btn btn-primary" ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>

示例.aspx.cs

protected void btnSubmit_Click(object sender, EventArgs e)
{
txtMessage.Text = "Success!";
}

4

1 回答 1

0

您需要移动 UpdatePanel 标签;您现在拥有它们的位置是您将整个模态框封装起来,而您只需要封装模态内容。

例如:

<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">    
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtMessage" runat="server"></asp:TextBox>
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<asp:Button CssClass="btn btn-primary" ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</form>
于 2014-01-22T15:56:14.213 回答