• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 879
  • Last Modified:

PageMethods c#

I have one project that I use PageMethods many times and works fine.

I started a new projetc and PageMethods does not work. It say:" PageMethods is not definied"

In the project that works my code is something like that:

Server code:

Public Sub Log()

end sub

And Javascript code:


My Scriptmanages is:

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnableScriptLocalization="true">

Anyone has any idea about this ?
Anderson Meneses
Anderson Meneses
3 Solutions
Please refer to this article


The main things to watch out is ..

1. The page method should be static
2. The method should be annotated with webmethod and script method

Hope this helps :)
Dominic AbrahamSr.Software EngineerCommented:
As in previous reply,
The page method should be static and should have [System.Web.Services.WebMethod]    attribute.
You will get a good details about the pagemethod usage from the below link


And check whether you have references to
<%@ Register Assembly="System.Web.Extensions,...... %> in your your page

Roopesh ReddyIT AnalystCommented:

I installed latest version of AJAX Control Toolkit from Nuget and tried creating a sample app.

It's working fine for me!

<ajaxToolkit:ToolkitScriptManager runat="server" ID="scriptManager1" EnablePageMethods="true">

    <input type="button" name="btn" value="Click" onclick="PageMethods.HelloWorld(OnSuccess,OnFailure);" />

    <script type="text/javascript">
        function OnSuccess(result) {

        function OnFailure(error) {

        public static string HelloWorld()
            return "Hello World";

Open in new window

Hope it helps u...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now