Introduction
How to access the Code behind method into java script.
Background
It will useful into some block of code in between to show the alert or confirmation message
Using the code
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");
}
}