I'm currently calling an asp.net function from JavaScript using the following code. However, I am trying to call a non-static method and when I remove the static field, the function does not fire. Is there any way to accomplish this? Thank you.
public partial class Test : System.Web.UI.Page
{
[WebMethod]
public static string HelloWorld(string name)
{
return string.Format("Hi {0}",name);
}
}
<script type="text/javascript">
function GreetingsFromServer() {
var name = 'Jalpesh';
PageMethods.HelloWorld(name,OnSuccess, OnError);
return false;
}
function OnSuccess(response) {
alert(response);
}
function OnError(error) {
alert(error);
}