Bonjour,

J'utilise depuis les ModalPopupExtender, qui fonctionnent très bien lorsqu'ils sont liés à un évènement en particulier !

J'aimerai cette fois en utiliser un dès le chargement de page, qui se déclenche cette fois suite à une condition du code C#, et non suite à un évènement.

Sauf qu'on moment où la fonction javascript qui récupère le ModalPopup est appelée, le ModalPopup n'a pas l'air d'exister, puisqu'il est chargé en dernier dans la page !

Mon javascript, récupéré sur le net :o :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<script language="javascript" type="text/javascript">
    //  keeps track of the delete button for the row
    //  that is going to be removed
 
    var _source;
    // keep track of the popup div
    var _popup;
 
    function showConfirm(){        
        //this._source = source;
        this._popup = $find('mdlPopup');
 
        //  find the confirm ModalPopup and show it    
        this._popup.show();
    }
 
    function okClick(){
        //  find the confirm ModalPopup and hide it    
        this._popup.hide();
        //  use the cached button as the postback source
        //__doPostBack(this._source.name, '');
    }
 
    function cancelClick(){
        //  find the confirm ModalPopup and hide it 
        this._popup.hide();
        //  clear the event source
        this._source = null;
        this._popup = null;
    }
</script>
le code ASPX
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
<cc2:ModalPopupExtender runat="server" ID="mdlPopup" BehaviorID="mdlPopup" TargetControlID="panelMsgPopup" PopupControlID="panelMsgPopup" 
    OkControlID="BtnOK" CancelControlID="BtnCancel" BackgroundCssClass="modalBackground" OnOkScript="okClick();" OnCancelScript="cancelClick();"></cc2:ModalPopupExtender>

le code C#

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
if (Request.Browser.Browser.ToUpper() == "IE")
        {  
            string strScript = "<script language=JavaScript>";
            strScript += "showConfirm();";
            strScript += "</script>";
            if (!this.ClientScript.IsClientScriptBlockRegistered("clientScript"))
                ClientScript.RegisterStartupScript(this.GetType(), "clientScript", strScript);             
        }
Avez-vous une astuce ou une idée du problème ?

Merci d'avance.