Execute JavaScript function from ASP.NET or codebehind C# code file
Execute a Javascript function from c# code:
Calling a JavaScript function from codebehind is quiet
simple, yet it confuses a lot of developers.
Here's how to do it. Declare a
JavaScript function in your code as shown below:
JavaScript function on aspx page :
<head runat="server">
<title>Call
JavaScript From CodeBehind</title>
<script
type="text/javascript">
function
alertMe()
{
alert('Hello');
}
</script>
</head>
C# code for call javascript function on aspx.cs page :
protected void Page_Load(object sender, EventArgs e)
{
if
(!ClientScript.IsStartupScriptRegistered("alert"))
{
Page.ClientScript.RegisterStartupScript(this.GetType(),
"alert", "alertMe();", true);
}
}
Learn more from past post How to Calling a Javascript function from c# code.
Other Asp.net Related Post:
- How to Bind Gridview Form database.
- Show gridview Row Details.
- Templatefield in gridview
- Introduction of Asp.net grid view Control.
- Example of Templatefield in gridview .
- Example of DropDownList inside GridView
- Check box in ASP.NET GridView
- Ckeck box list example using javascript in grid.
- Check box in ASP.NET GridView
- Show grid view row details in to tooltip.
- How to Bind Gridview Form database.
- Show gridview Row Details And Give Example.
- Example of Templatefield in asp.net gridview.
- Example of DropDownList inside GridView control
- Introduction of Asp.net grid view Control.
- Example of C# for Bind Data to asp.net Textbox inside gridview control
- Bind Data to asp.net textbox control in inside of gridview Using C# Example
Comments
Post a Comment