Introduction: Here I will tell you how you can call javascript and jquery function
from codebehind.
Descirption:
Here I will tell you how you can call javascript and jquery function from codebehind.
If you are using scriptmanager on page then you can call
ScriptManager instance.
If you are not using script manager then you can call
Page.ClientScript instance
Implementation:
In Code Behind
protected void MyButton_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript",
"MyFunction
();", true);
}
protected void MyButton_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.GetType(), "myScript",
"
MyFunction
();", true);
}
No comments:
Post a Comment