Monday, April 5, 2010

Invoke a server-side function with JavaScript in ASP .NET

It is very easy once you define any event on control..
IF you want to call your private method, you can create a temporary button
and hide it with "diplay:none" and just write its click event. In that click event
you can call your private function. As easy as that.
 

ASP .NET Code: 

protected void Button1_Click(object sender, EventArgs e)
{
   FunctionName();
}
 
Javascript Code to call Button1 Event: 
 
document.getElementById("Button1").click();
It will call the Button1_Click event and click event will call your function.
 

No comments:

Post a Comment