smarx.com

developing for the new web

If you're seeing "PageMethods is not defined"...

You may be missing EnablePageMethods="true" on your ScriptManager. Thanks to Joe Stagner for that tip. This has come up a number of times on the forums. It's a change between the RC and 1.0, and though it's in the web service documentation, it's strangely absent from the "differences" doc.

Speaking of the documentation, it's now available as a download. (This has been frequently requested.)

Chris Haines said:
I spent a while trying to figure out why I was getting "PageMethods is not defined" (Firefox) or "PageMethods is undefined" (IE).

I had EnablePageMethods="true" on my ScriptManager. I had [WebMethod] on my static page method.

Turns out I had a bit of stray text on my code-in-front aspx page that was causing the javascript to go wrong. I had a few chars of text before my <%@ Page .. %> declaration that somehow messed up the javascript.

Thought I'd share this with the world because I couldn't find anything when I searched.
Jules S said:
Similar to Chris Haines, I had EnablePageMethods="true" in my ScriptManager and [WebMethod] on my static page method. I found that the method had to be on an aspx page rather than the Master page I had originally placed it. Weird.
AttilaBal said:
- I installed the latest AJAX from ajax.asp.com
- I added the EnablePageMethods="True" in the scriptmanager
- I added using System.Web.Services; in my cs file
- I added [WebMethod] befor my method

But it sed: PageMethods is undefined

So.... the article is s*it.... :S
Dan said:
Unfortunately it's not working when call PageMethods from an UserControl...
Tien said:
In my case, it works perfectly with IE7 but Firefox does not work at all.....
Ray Akkanson said:
It works fine on IE but not Firefox either

Ray akkanson
xxx said:
xxx
said:
said:
joeyb said:
Try putting the static webmethod in a .aspx page. You cannot have your static webmethod in a user control (ascx) or a master page for some reason.

Add your own comment

Your name:
Your website/mailto:
Your comment: