'PageMethods' is undefined


Robert Johnson

I have an ASP.NET 3.5 (+SP1) Web application on a clean image, with no beta
versions of "Atlas" or the 1.1 Framework installed... XP Pro/SP3 + patches
and updates.

I'm getting the JavaScript error: 'PageMethods' is undefined when attempting
to execute this line:

I have googled this a bunch, and most of the issues and associated
resolution are nicely summarized in this small list:

.... but none of the issues presented there are relevant to me (or I have
verified that things are as they should be with respect to those particular
possible problems)... and I still am encountering the error.

In brief
1. I do have a ScriptManager with EnablePageMethods=true
2. The IIS Web site's virtual dir is not configured for 1.1 (but for clr
3. the Web.config files match (between my app and a working sample app)...
has the WebServices section, etc...
4. I'm *not* using a pre-release version of Atlas (never installed on this

What else can I look at?

I am fortunate to have a working example - same Framework version and all. I
have compared Web.config and the entries match. The big difference is that
the sample app is a Web site using the built-inWeb server, whereas my app is
the Web Application project type that using IIS.

Your suggestions are appreciated, as I'm feeling stuck on this one.

Robert Johnson

Here is the answer - for anybody researching this issue ('PageMethods' is

I was getting that issue because my app didn't have any page method defined
(i.e., a public static method with the [System.Web.Services.WebMethod]

You can reproduce the issue (really, non issue when you understand what's
going on) like this:

1. Create a new ASP.NET Web app

2. add a ScriptManager to default.aspx, and set EnablePageMethods="True"

3. run the app and view the page source.
You will see in the rendered html an *absence* of the following
PageMethods.prototype = {...}

4. Stop the app, then add a method to default.aspx.cs.
Make the method static and public decorated with the
[System.Web.Services.WebMethod] attribute.

5. Run the app and view the rendered page source. This time you will see
PageMethods.prototype = {...} in the page source.

Apparently ASP.NET will not define the PageMethods in the client markup if
there is no server-side page method to call. Makes perfect sense.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads