[英]how to calling asp.net function from javascript for the non-static method?
i am calling asp.net function from javascript using this code as given below : but i need to call non-static method. 我正在使用以下代码从JavaScript调用asp.net函数:但我需要调用非静态方法。 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);
}
不可能,也不鼓励这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.