Twitter引导模态与Asp.net Webforms消失

时间:2013-07-30 14:02:30

标签: twitter-bootstrap webforms

我在Asp.net Webforms中使用twitter bootstrap模式。

事件发生后,点击 btnSubmit 按钮,模态消失。

如何维持模态激活?

Example.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>

<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>

Example.aspx.cs

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

1 个答案:

答案 0 :(得分: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>