我的网站使用了一个主页面,默认情况下我将模态弹出窗格div(id =“myModal”)置于隐藏状态。我正在使用twitter bootstrap模式弹出窗口(modal.js)和jQuery.load()来填充#myModal的主体和另一个名为Feedback.aspx的aspx页面。
模式按预期弹出并显示feedback.aspx内容(这是一个完整的页面,包括doctype,HTML,head和body标签......也许它不应该是?),但因为它没有显示在iframe,当我提交页面时,它会进行PostBack并使用整个feedback.aspx页面刷新父页面。
我希望feedback.aspx只是在模态弹出窗口而不是整个父页面中刷新。
我已尝试在UpdatePanel(使用ScriptManager)中包装feedback.aspx页面的整个正文内容,当我现在单击提交按钮时,数据将保存到数据库,并且模态窗口保持打开状态,但是我的ModalAlertBox消息不显示。我假设我的模态窗口没有更新。
我已尝试将updatepanel.update()添加到我的submitbutton.click事件中,但它仍然无效。
任何帮助表示赞赏! 谢谢!
母版
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div id="myModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"></div>
Feedback.aspx(用作#myModal内容):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
...
</head>
<body>
<form ...>
<asp:ScriptManager ID="ModalScriptManager" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="ModalUpdatePanel" runat="server" UpdateMode="Always">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnModalSubmit" EventName="Click" />
</Triggers>
<ContentTemplate>
<fieldset>
...
<div id="ModalAlertBox" class="alert" runat="server" visible="false">
<button type="button" class="close" data-dismiss="alert">×</button>
<asp:Label ID="lblModalMsg" runat="server" Text=""></asp:Label>
</div>
...
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>
Feedback.aspx.vb
Protected Sub btnModalSubmit_Click(sender As Object, e As System.EventArgs) Handles btnModalSubmit.Click
Try
GetAccount(_Account)
If _Account.Exists Then
... Save Logic ...
lblModalMsg.Text = "Success Msg."
Else
lblModalMsg.Text = "Fail Msg."
End If
Catch ex As Exception
clsExceptionHandler.log(ex)
lblModalMsg.Text = "Unexpected Error Msg."
End Try
Me.ModalAlertBox.Visible = True
Me.ModalUpdatePanel.Update()
End Sub
答案 0 :(得分:1)
这已经解决了。我只在UpdatePanel中包装了ModalAlertBox而不是整个表单,它修复了问题。
....
<asp:UpdatePanel ID="ModalUpdatePanel" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnModalSubmit" EventName="Click" />
</Triggers>
<ContentTemplate>
<fieldset>
<div id="ModalAlertBox" class="alert" runat="server" visible="false">
<button type="button" class="close" data-dismiss="alert">×</button>
<asp:Label ID="lblModalMsg" runat="server"></asp:Label>
</div>
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
....