質問

This questions was already answered here - How to specify javascript to run when ModalPopupExtender is shown - but the accepted solution is not working for me.

The modalpopupextender is declared as below:

<ajaxtoolkit:ModalPopupExtender ID="mpe" runat="server" TargetControlID="btn"
        PopupControlID="pnlModal" PopupDragHandleControlID="pnlModalDragHandle"   BackgroundCssClass="modalBackground"
    CancelControlID="btnModal" DropShadow="true"/> 

The showing / hiding works fine. What does not work is linking a client script to the showing event of the modal popup extender. Based on the original question, I tried:

 <script type="text/javascript">
    function pageLoad() {
    var popup = $find('mpe');
    popup.add_shown(SetShowing);
    }

function SetShowing() {
    alert('showing');
  }

 </script>

Nothing happened. No alert, no errors. Reading further in the original post, I even added this line in the script: Sys.Application.add_load(pageLoad);

The additional line had no effect. Any ideas why the original answer is not working? Thanks, I have been trying for hours.

役に立ちましたか?

解決 2

I ended up having to attack this problem another way. None of the suggestions were able to successfully detect when the modalpopupextender was displayed. I instead changed my approach to handle user actions on the shown elements - like focusing on a textbox, etc. I could be confident the modalpopupextender was displayed if the user was interacting with it.

If you came here, I would direct you to the original post here - How to specify javascript to run when ModalPopupExtender is shown - and hope you were more successful than I was.

Thank you to everyone who commented, I sincerely appreciate your time.

他のヒント

I am not familiar with "modalpopupextender",

but why not just use some jquery?

$(document).ready(function(){
     if ($('#mpe').is(':visible')){     
         //code for when MPE is visible here

     }

});

jquery documentation

http://jsfiddle.net/N62g5/8/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top