不能从Javascript调用的页面方法 [英] Pagemethods not Calling from Javascript
本文介绍了不能从Javascript调用的页面方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我有一个页面方法可以从数据库中检索客户名称.但是在我的javascript文件中使用该pagemethod调用时,它会显示类似
的错误
" PageMethod未定义"
我认为我的Javascript文件不知道PageMethods ...
请给我您解决该问题的建议....
我的Javascript包含...
Hi All,
I have an pagemethod to retrieve the custname from database. But while using that pagemethod call inside my javascript file it shows error like
"PageMethod not Defined"
I think PageMethods are unknown to my Javascript file...
Please give me your suggestions to solve this issue....
My Javascript contains...
function CallMe(src,dest)
{
var ctrl = document.getElementById(src);
PageMethods.GetContactName(ctrl.value, CallSuccess, CallFailed, dest); //Not called
}
function CallSuccess(res, destCtrl)
{
var dest = document.getElementById(destCtrl);
dest.value = res;
}
function CallFailed(res, destCtrl)
{
alert(res.get_message());
}
我的 MasterPage 内容包含...
My MasterPage Content contains...
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true">
我后面的代码...
My code behind...
[System.Web.Services.WebMethod]
public static string GetContactname(string custid)
{
//Code to retrieve custname
}
正在初始化加载...
Initialize onload...
txt_custid.Attributes.Add("onblur", "javascript: CallMe(''" + txt_custid.ClientID + "'', ''" + txt_custname.ClientID + "'')");
推荐答案
希望此链接有助于解决您的问题,
从ASPNET中的Javascript调用WebMethod [ ^ ]
Hope this link helps to solve your problem,
Call WebMethod from Javascript in ASPNET[^]
这篇关于不能从Javascript调用的页面方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文