Loading ...

How to call javascript when used update panel | CodeAsp.Net

How to call javascript when used update panel

0 (0votes)

Today, I would like to share that how to call a javascript code at aspx.cs side when we use updatepanel. Because when we used the update panel then asynchronous request  goes to server. So that we have to register the script to the script manager and then it works perfectly.

Please note that we have to register with scriptmanager not with scriptmanager1 or something else.


protected void button1_click(object sender, EventArgs e) 


string script = @" function MessageAlert()
alert('message sent');

//we have to register the script with script manager ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "MyScript", script, true)


So now I have to discuss about parameters which this method takes.(this is static function)

RegisterClientScriptBlock(control : Control, type : Type, key : String, script : String, addScriptTags : boolean)

it takes five parameter:

1.control: Control where used this script.(here I am using this because script is at current page.)

2. type: type of client script.(accecss through typeof operator)

3.key: unique identifier.(this parameter is string type and must unique)

4.script:script which has to be regitser.

5.addscript tag:it is used for add the script tag or not.it takes only boolean value i.e. true/false.


Hope this will help....

Comments (no comments yet)

Top Posts