Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 'PageMethods' is undefined

Reply
Thread Tools

'PageMethods' is undefined

 
 
Robert Johnson
Guest
Posts: n/a
 
      01-21-2009
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:
PageMethods.ExecuteCommand(...)

I have googled this a bunch, and most of the issues and associated
resolution are nicely summarized in this small list:
http://chiragrdarji.wordpress.com/20...-is-undefined/

.... 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
2.x)
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
box)

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.





 
Reply With Quote
 
 
 
 
Robert Johnson
Guest
Posts: n/a
 
      01-22-2009
Here is the answer - for anybody researching this issue ('PageMethods' is
undefined):

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]
attribute).

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.

-HTH



"Robert Johnson" <> wrote in message
news:e%...
>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:
> PageMethods.ExecuteCommand(...)
>
> I have googled this a bunch, and most of the issues and associated
> resolution are nicely summarized in this small list:
> http://chiragrdarji.wordpress.com/20...-is-undefined/
>
> ... 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
> 2.x)
> 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
> box)
>
> 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.
>
>
>
>
>



 
Reply With Quote
 
 
 
 
ktsang ktsang is offline
Junior Member
Join Date: May 2010
Posts: 1
 
      05-05-2010
You need to make sure the webmethod you are calling is a static method
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
typeof x == 'undefined' or x == undefined? -Lost Javascript 13 01-31-2007 12:04 AM
undefined vs. undefined (was: new Array() vs []) VK Javascript 45 09-12-2006 05:26 PM
pass an undefined number of datasets Andreas VHDL 5 05-31-2005 06:06 PM
undefined behavior or not undefined behavior? That is the question Mantorok Redgormor C Programming 70 02-17-2004 02:46 PM
NET::NNTP Undefined value error Gene Mat Perl 0 07-07-2003 11:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57