防止 ModalPopupExtender 在回发期间/之后关闭
如何防止我的 asp:ModalPopupExtender 在回发到服务器之后或期间关闭?
这是我的代码:
JAVASCRIPT
// Confirm popup Ok button
function OnOk() {
$('#confirmPopup').hide();
ClickSaveButton(); // does a postback
ShowGridPopup();
}
ASP.NET AJAX
<asp:ModalPopupExtender BehaviorID="confirmPopup" ID="confirmPopup" runat="server"
TargetControlID="butConfirm" PopupControlID="ConfirmView" BackgroundCssClass="modalBackground"
OnOkScript="OnOk();" OnCancelScript="OnCancel();"
OkControlID="yesButton" CancelControlID="noButton">
</asp:ModalPopupExtender>
无论我在回发方法之前还是之后调用 ShowGridPopup()
ClickSaveButton( )
,弹出窗口仍然消失。我怎样才能防止这种情况发生?
编辑
这是ShowGridPopup()
和ClickSaveButton()
的代码
function ShowGridPopup() {
if (getID() == "Popup1") {
ShowGridPopup1();
} else if (getID() == "Popup2") {
ShowGridPopup2();
}
}
function ClickSaveButton() {
var _id = $('a[id$="butSave"]').attr("ID");
__doPostBack(_id.replace("_", "$"), '');
}
How do I prevent my asp:ModalPopupExtender from closing after or during a postback to the server??
Here is my code:
JAVASCRIPT
// Confirm popup Ok button
function OnOk() {
$('#confirmPopup').hide();
ClickSaveButton(); // does a postback
ShowGridPopup();
}
ASP.NET AJAX
<asp:ModalPopupExtender BehaviorID="confirmPopup" ID="confirmPopup" runat="server"
TargetControlID="butConfirm" PopupControlID="ConfirmView" BackgroundCssClass="modalBackground"
OnOkScript="OnOk();" OnCancelScript="OnCancel();"
OkControlID="yesButton" CancelControlID="noButton">
</asp:ModalPopupExtender>
No matter if I call ShowGridPopup()
before or after the postback method ClickSaveButton()
, the popup still dissapears. How can I prevent this?
EDIT
Here is the code for the ShowGridPopup()
and ClickSaveButton()
function ShowGridPopup() {
if (getID() == "Popup1") {
ShowGridPopup1();
} else if (getID() == "Popup2") {
ShowGridPopup2();
}
}
function ClickSaveButton() {
var _id = $('a[id$="butSave"]').attr("ID");
__doPostBack(_id.replace("_", "$"), '');
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该使用
UpdatePanel
,这样 ModalPopupExtender 在回发后就不会隐藏。请参阅下面的示例:Aspx:
代码隐藏:
You should use
UpdatePanel
, so the ModalPopupExtender won't be hidden after postback. See this example below :Aspx:
Code behind :
将 ModalPopupExtender1.Show() 与更新面板一起使用以避免整个页面刷新。这对我来说非常有效。
Use, ModalPopupExtender1.Show() with update panel to avoid the whole page refresh. This has worked perfectly for me.
我找到了一种方法来绕过这个问题,这是我的解决方案:您必须在 ASP 中的服务器端创建一个新的
HiddenField
控制器,该控制器将用于存储的 ID ModalPopupExtender
是你想在回发后显示的,如果没有弹出窗口显示,则设置为 null。接下来,在使用保存事件之前,我们需要将 ID 设置为
HiddenField
现在,在后面的代码中,我们需要做的就是检查
HiddenField
的值文本字段,我们可以相应地在正确的弹出窗口上执行.Show()
。I have found a way to by pass this, here is my solution: You have to create a new
HiddenField
controller from the server-side in ASP that will be used to store the ID of theModalPopupExtender
that you want to show after postback, it is set to null if there is no popup to be shown.Next, we need to set the ID to the
HiddenField
before we use the save eventNow, in the code behind, all we need to do is check the value of the
HiddenField
text field and we can just do a.Show()
on the correct popup accordingly.