Skip to content Skip to sidebar Skip to footer

Trouble Getting A Reference To A ModalPopupExtender Using Javascript

I am trying to use the following code to get a reference to a modalpopupextender, but when I check the value of the javascript variable 'modal' it is always null. What is the prop

Solution 1:

I suspected that part of the problem was the popupextenders had not been rendered at the time the script was being called. So after googling I found this post: http://forums.asp.net/p/1413275/3112082.aspx#3112082. Here is the solution I ended up with:

.aspx

    <ajaxToolkit:ModalPopupExtender ID="mpeResetConfirm" runat="server"
    TargetControlID="btnReset" PopupControlID="pnlConfirmation" BehaviorID="modal1"/>
    <script type="text/javascript" language="javascript">
        function pageLoad() 
        {
            var modal = $find('modal1');
            debugger;
            $find('modal1').add_showing(
                function()
                {
                    alert("Modal popup will be showing");
                }
           );  
        }
    </script>

Solution 2:

Try

$find('IDofModalPopupExtender')

instead of

$find('<%=modal1.ClientID%>')

Post a Comment for "Trouble Getting A Reference To A ModalPopupExtender Using Javascript"