Reputation: 41
i am calling asp.net function from javascript using this code as given below : but i need to call non-static method. when i remove the static field function not firing. There is any way to do 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);
}
Upvotes: 1
Views: 671