ModalPopupExtender how to close when clicking outside of modal

0

Working on a legal project, I'm using ModalPopupExtender of AjaxToolKit .

I have already identified if I can use the OkControlID and CancelControlID attributes to define which control, a Button for example, closes the modal.

<cc1:ModalPopupExtender ID="ModalPopupExtender1" 
     runat="server"
     OkControlID="btnOkay"
     CancelControlID="btnCancel">
</cc1:ModalPopupExtender>

What I would like to know is if there is a possibility of closing Modal by clicking outside the area of the Modal window that was opened.

Is there any attribute or other code to do this?

    
asked by anonymous 29.05.2017 / 20:02

1 answer

0

Following the link from @Marconi, the OS link in English: link

The proposed solution is to add a listener to the click event of background that modal displays, and in that case close hide modal:

  • Set the class name of background :

  • With jQuery , use the click event:

  • jQuery('.jsMpeBackground').click(function () { var id = jQuery(this).attr('id').replace('_backgroundElement', ''); $find(id).hide(); });

    I preferred to change the line hiding the modal. This is because I want the callback function to be executed when the modal is closed, so I changed that line:

    $find(id).hide();
    

    by this:

    $('#btnOkay').click();
    
        
    29.05.2017 / 21:34