PageMethods revisited... RRS feed

  • Question

  • User1583495713 posted


    I've red the entire thread : PageMethods and now I'm here with this issue that PageMethods is undefined or today after 9 years there's an error message in Visual Studio 2013 Community saying Cannot find name 'PageMethods'.  The image below is showing the error and this is a Typescript file but I tried a .JS directly and I get the same problem


    The ASPX has the ScriptManager, it has the EnablePageMethods="true", the method is public static with the WebMethod attribute as it should and the javascript is added in the header so I really don't see why PageMethods isn't recognized in JS

    Thursday, January 29, 2015 5:44 AM

All replies

  • User-271186128 posted

    Hi GearWord,

    According to your description, I create a sample using the following code. It seems that everything worked well. You could refer to it.

        <script type="text/javascript">
            function Myfunction(e) {
                var str = PageMethods.SendValues("AAA", OnSuccess);
            function OnSuccess(response, userContext, methodName) {
            <asp:Button ID="Button1" runat="server" OnClientClick="Myfunction(event);" Text="Button" />
            <asp:ScriptManager ID="ScriptManager1" EnablePageMethods="true" runat="server"></asp:ScriptManager>

    Code Behind:

            public static string SendValues(string name)
                return "Hello " + name;

    Note: I also use Visual Studio 2013.

    Best Regards,

    Friday, January 30, 2015 12:54 AM
  • User1583495713 posted


    Well I did the same over here and yet the PageMethods is undefined.  It simply doesn't exist at all.  Where is this class located ? Do I miss a reference somehow ?  I'm not sure because everything else works perfectly except PageMethods doesn't exist

    I have the reference System.Web.Extensions


    Friday, January 30, 2015 7:18 AM
  • User1583495713 posted

    I see it works in the script directly inside the aspx markup however the original message states that it's from a .TS or let say a .JS that the PageMethods is undefined and doesn't exist.
    Now believe it or not I created the method like your Myfunction and tried to call Myfunction from the .TS file or the .JS file if you whish and nope it doesn't see it at all.  It's like everything I declare in a script inside the aspx markup isn't available to .TS or .JS file

    Friday, January 30, 2015 7:21 AM
  • User1583495713 posted

    I miss Silverlight..........

    Friday, January 30, 2015 7:24 AM