Search code examples
ajaxcontroltoolkit

ModalPopupExtender


I must create ModalPopupExtender. for this, I create one simple application and all my expectation wrok. But when i add my popup in master page it doesn't work, How I can fix this problem?

my popup

<asp:Button ID="Button1" runat="server" Text="Click here to show iframe in modalpopup" />
      <asp:ModalPopupExtender ID="ModalPopupExtender1" BackgroundCssClass="ModalPopupBG"
         runat="server" CancelControlID="btnCancel" OkControlID="btnOkay" TargetControlID="Button1"
         PopupControlID="Panel1" Drag="true" PopupDragHandleControlID="PopupHeader">
      </asp:ModalPopupExtender>
      <div id="Panel1" style="display: none;" class="popupConfirmation">
         <iframe id="frameeditexpanse" frameborder="0" src="InnerPage.aspx" height="161">
         </iframe>
         <div class="popup_Buttons" style="display: none">
            <input id="btnOkay" value="Done" type="button" />
            <input id="btnCancel" value="Cancel" type="button" />
         </div>
      </div>

my script in InnerPage.aspx

<script language="javascript" type="text/javascript">
      function okay() {
         window.parent.document.getElementById('btnOkay').click();
      }
      function cancel() {
         window.parent.document.getElementById('btnCancel').click();
      }
   </script>

Solution

  • place this script on same page with extender

    <script type="text/javascript">
        function clickOk() {
            $get("<%= btnOkay.ClientID %>").click();
        }
    
        function clickCancel() {
            $get("<%= btnCancel.ClientID %>").click();
        }
    </script>
    

    and instead of parent.window.document.getElementById().click() use parent.window.clickOk() and parent.window.clickCancel()