javascript 使用 jQuery 显示一个 asp:ModalPopupExtender
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6143485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
showing an asp:ModalPopupExtender using jQuery
提问by JF Beaulieu
I am trying to show an asp:ModalPopupExtender using jQuery, without any success. Here is what I have :
我正在尝试使用 jQuery 显示一个 asp:ModalPopupExtender,但没有成功。这是我所拥有的:
ASP.NET
ASP.NET
<asp:ModalPopupExtender BehaviorID="confirmPopup" ID="confirmPopup" runat="server" />
JAVASCRIPT
爪哇脚本
function ShowConfirmPopup() {
var _id = '#<%= confirmPopup.ClientID %>';
var modal = $find(_id);
modal.show();
}
What happens is that modal
is always equal to null
, so the popup never gets shown. What am I doing wrong?
发生的情况是它modal
始终等于null
,因此永远不会显示弹出窗口。我究竟做错了什么?
回答by Frédéric Hamidi
$find()is not part of jQuery, but of ASP.NET AJAX. Therefore, you should not prefix the behavior id with a hash sign:
$find()不是 jQuery 的一部分,而是ASP.NET AJAX 的一部分。因此,您不应在行为 id 前加上井号:
function ShowConfirmPopup()
{
var modal = $find("confirmPopup");
modal.show();
}