c# - Show User Control through Static Method -


i have been researching this, haven't been able find far.

currently, using javascript alert box on asp page:

public static class alert {     public static void show(string message)     {         string script = "<script type=\"text/javascript\">alert('" + message + "');</script>";         page page = httpcontext.current.currenthandler page;          if (!page.clientscript.isstartupscriptregistered("alert"))         {             page.clientscript.registerstartupscript(typeof(alert), "alert", script);         }     } }  

i able call code behind by: alert.show("text");

my plan replace javascript alert utilizing ajaxcontroltoolkit's modalpopupextender. creating user control looks this:

            <ajax:modalpopupextender id="mpalert" runat="server" popupcontrolid=""                  targetcontrolid="btnexport"  okcontrolid="btnok">             </ajax:modalpopupextender>             <asp:panel id="pnlsteps" runat="server" backcolor="#c5d9fc"  width="10%"             bordercolor="#093e9a" borderstyle="double" borderwidth="5px"             style="border-radius: 10px; padding: 5px;">                                 <div>                 <asp:literal id="lsteps" runat="server" />                 </div>                 <div>                 <input id="btnok" type="button" value="ok" />                 </div>             </asp:panel> 

i wondering if there way can create static method show codebehind, similar how used javascript alert. i'd able wrap in class call ajaxalert.show(), without having call in aspx file. still rough idea, if more details needed, let me know.

you can show modalpopupextender codebehind. therefore need invisible trigger button.

mpalert.show(); 

so set targetcontrolid of modalpopupextender hidden button:

<asp:button id="hid_showdialog" style="display: none" runat="server" /> 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -