Calling the Asp.net Code Behind method into Javascript

Aug 9, 2010 Posted by Lara Kannan
Blocks of code should be set as style "Formatted" like this:


<script language="javascript" type="text/javascript">
function call_me()
{

var Temp= confirm("Hit from ClientSide");

if(Temp)
{
alert("True");
__doPostBack('btnHdn','onserverclick');
}
else
{
alert("false");
}

}
</script>

From Button event


<input type="button" runat ="server"
onclick="call_me();" id="btnClick" value="PRESS" />

Calling this method into java script function.


public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Call_Server(Object sender, EventArgs e)
{
Response.Write("Calling Server Side Event");
}

}

Share
Labels: ,

Post a Comment