How to specify javascript to run when ModalPopupExtender is shown

前端 未结 8 644
有刺的猬
有刺的猬 2020-12-28 13:15

The ASP.NET AJAX ModalPopupExtender has OnCancelScript and OnOkScript properties, but it doesn\'t seem to have an OnShowScri

相关标签:
8条回答
  • 2020-12-28 13:32

    The ModalPopupExtender modifies the button/hyperlink that you tell it to be the "trigger" element. The onclick script I add triggers before the popup is shown. I want script to fire after the popup is shown.

    Also, still leaves me with the problem of when I show the modal from server side.

    0 讨论(0)
  • 2020-12-28 13:33
    var launch = false;
    
    function launchModal() {
        launch = true;
    }
    
    function pageLoad() {
        if (launch) {
              var ModalPedimento = $find('ModalPopupExtender_Pedimento');
              ModalPedimento.show();
              ModalPedimento.add_shown(SetFocus);
        }
    }
    
    function SetFocus() {
        $get('TriggerClientId').focus();
    }
    
    0 讨论(0)
  • 2020-12-28 13:39

    TinyMCE work on invisible textbox if you hide it with css (display:none;) You make an "onclick" event on TargetControlID, for init TinyMCE, if you use also an updatepanel

    0 讨论(0)
  • 2020-12-28 13:43

    You should use the BehaviorID value mpeBID of your ModalPopupExtender.

    function pageLoad() {
        $find('mpeBID').add_shown(HideMediaPlayer);
    }
    
    function HideMediaPlayer() {
        var divMovie = $get('<%=divMovie.ClientID%>');
        divMovie.style.display = "none";
    }
    
    0 讨论(0)
  • 2020-12-28 13:47

    Here's a simple way to do it in markup:

    <ajaxToolkit:ModalPopupExtender 
                    ID="ModalPopupExtender2" runat="server" 
                    TargetControlID="lnk_OpenGame" 
                    PopupControlID="Panel1" 
                    BehaviorID="SilverPracticeBehaviorID"  >
                <Animations>
                    <OnShown>
                         <ScriptAction Script="InitializeGame();" />  
                    </OnShown>
                </Animations>                
    </ajaxToolkit:ModalPopupExtender>
    
    0 讨论(0)
  • 2020-12-28 13:49

    For two modal forms:

    var launch = false;
    var NameObject = '';
    
    function launchModal(ModalPopupExtender) {
        launch = true;
        NameObject = ModalPopupExtender;
    }
    
    function pageLoad() {
        if (launch) {
            var ModalObject = $find(NameObject);
            ModalObject.show();
            ModalObject.add_shown(SetFocus);
                    }
    } 
    
    function SetFocus() {
        $get('TriggerClientId').focus();
    }
    

    Server side: behand

    protected void btnNuevo_Click(object sender, EventArgs e)
    {
        //Para recuperar el formulario modal desde el lado del sercidor
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script>launchModal('" + ModalPopupExtender_Factura.ID.ToString() + "');</script>", false);
    }
    
    0 讨论(0)
提交回复
热议问题