Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
5.00/5 (3 votes)
hi i get error pageMethod is undefined
my code is:

JavaScript
script  type="text/javascript">
          function runTest() {
              var ffg = PageMethods.Test();

              alert(ffg);

          }
    </script>


and add this in .aspx page
ASP.NET
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>

my default.cs page is
C#
[System.Web.Services.WebMethod]
        public string Test()
        {
            return "hello";
        }
Posted
Updated 13-Mar-13 0:24am
v5

Your Test method needs to be static

C#
[System.Web.Services.WebMethod]
 public static string Test()
 {
     return "hello";
 }
 
Share this answer
 
Comments
jiji2663 13-Mar-13 6:59am    
i use this
but also get this error
mosi98 13-Mar-13 7:05am    
i test the static but dont run the method
JavaScript
function runTest() {
        PageMethods.Test(OnSucceeded, OnFailed);
    }

    function OnSucceeded(response) {

        alert(response);
    }
    function OnFailed(error) {
        alert(error);
    }


C#
[System.Web.Services.WebMethod]
       public static string Test()
       {
           return "hello";
       }
 
Share this answer
 

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