Search code examples
javascriptjqueryasp.netmodalpopupextender

showing an asp:ModalPopupExtender using jQuery


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?


Solution

  • $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();
    }