我需要从ASP.Net 2.0框架中的Java脚本函数调用服务器端方法。对此有任何建议。
先谢谢
答案 0 :(得分:1)
试试这个
function focuslost() {
mainForm.StartUpdating();
var pagePath = window.location.pathname;
$.ajax({
type: "POST",
url: pagePath + "/TextChanged",
data: ("{ 'pNTID':'" + $("#<%= txtNTID.txtClientId%>").val()) + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function(XMLHttpRequest, textStatus, errorThrown) {
mainForm.EndUpdating()
},
success:
function(result) {
if (result.d.length > 0) {
}
mainForm.EndUpdating()
}
});
}
[WebMethod]
public static string TextChanged(string pNTID)
{
retrun "";
}
答案 1 :(得分:0)
使用WebMethod或AjaxMethod。检查下面
http://www.xdevsoftware.com/blog/post/Call-WebMethod-from-Javascript-in-ASPNET.aspx