Click here to Skip to main content
15,905,913 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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());
 }


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 + "')");
Posted
Updated 18-Jul-11 1:52am
v4

1 solution

Hope this link helps to solve your problem,

Call WebMethod from Javascript in ASPNET[^]
 
Share this answer
 
Comments
J.Karthick 18-Jul-11 5:44am    
No yar...Code is Corect..

I dont know why PageMethods are unknown to my Javascript

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900