Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple RegisterClientScriptBlock's

Tags:

asp.net

I want to call 3 javascript functions on my .cs file, I tried this:

protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                ClientScriptManager script = Page.ClientScript;
                ClientScriptManager script2 = Page.ClientScript;
                ClientScriptManager script3 = Page.ClientScript;

                script.RegisterClientScriptBlock(this.GetType(), "key", "centerPopup1()", true);
                script2.RegisterClientScriptBlock(this.GetType(), "key", "loadPopup1()", true);
                script3.RegisterClientScriptBlock(this.GetType(), "key", "msg1()", true);

            }
        }

With no success, nothing happens on my Postbacks, but if I try just calling one of these functions, it works.

like image 210
Jorg Ancrath Avatar asked Aug 06 '12 20:08

Jorg Ancrath


1 Answers

I believer you can only Register one StartupScript Block and multiple ClientScriptBlocks (different keys) Instead of creating multiple; have them next to one another.

Startup : will load in the Form ClientScript: bottom of page

script.RegisterClientScriptBlock(this.GetType(), "key", "centerPopup1(); 
loadPopUp1();  msg1();", true);
like image 64
Dane Balia Avatar answered Oct 14 '22 17:10

Dane Balia