showing an asp:ModalPopupExtender using jQuery

JF Beaulieu picture JF Beaulieu · May 26, 2011 · Viewed 11.1k times · Source

I am trying to show an asp:ModalPopupExtender using jQuery, without any success. Here is what I have :

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?

Answer

Fr&#233;d&#233;ric Hamidi picture Frédéric Hamidi · May 26, 2011

$find() is not part of jQuery, but of ASP.NET AJAX. Therefore, you should not prefix the behavior id with a hash sign:

function ShowConfirmPopup()
{
    var modal = $find("confirmPopup");
    modal.show();
}