PageMethods c#

Posted on 2012-08-25
Last Modified: 2012-08-28
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 ?
Question by:berechit
    LVL 21

    Assisted Solution

    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 :)

    Assisted Solution

    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

    LVL 23

    Accepted Solution


    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...

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now