How to execute JavaScript Function from ASP.NET Code Behind
How to execute JavaScript Function from ASP.NET Code Behind:
You have a JavaScript function and you want to execute it
from ASP.NET code behind file. You can achieve this by using
RegisterStartupScript method of ClientScript class as shown below:
Following JavaScript function in your code:
<script type="text/javascript">
function
SayMeHello() {
alert('Hello');
}
</script>
In order to call it from code behind:
if
(!ClientScript.IsStartupScriptRegistered("helloAlert"))
{
Page.ClientScript.RegisterStartupScript(
this.GetType(),
"helloAlert",
"SayMeHello();",
true);
}
Other Related Post :
- What is ASP.net Programming Part 2,Chat web application in asp.net programming
- Sql Query for asp.net Programming ,How to get Server IP, How to create graph in asp.net:
Comments
Post a Comment