This will work for you,
At .aspx Page :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Call Jquery function from code behind</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function CallFunction() {
alert("Test");
}
</script>
</div>
</form>
</body>
</html>
At Code Behind (aspx.cs) Page:
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'> CallFunction();</script>", false);
}
At .aspx Page :
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Call Jquery function from code behind</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function CallFunction() {
alert("Test");
}
</script>
</div>
</form>
</body>
</html>
At Code Behind (aspx.cs) Page:
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'> CallFunction();</script>", false);
}
0 comments:
Post a Comment