Yes, just attribute your methods as WebMethod's in your page/user controls. The code that is emitted, allows you to do a PageMethods.MethodName call to execute it via Javascript, or if you're declaratively using it, use pageMethod instead of serviceMethod.
You should also note that in pageMethod, you don't need to specify a url.
Have you actually tried this and managed to get it to work?
I know the theory but even on simple methods I get an exception raised that suggests that the method call to the server is incorrect, even though I am using the PageMethods.{methodname} proxy that is generated. I was under the
impression that this problem would be fixed in later builds that are released. Bertrand Leroy was unable to duplicate but mentions that it may be because he already has a later build with that fixed, but which has not been publicly released yet.
stevepuri
Member
14 Points
4 Posts
Calling methods on aspx and ascx pages ?
Oct 29, 2005 04:50 AM|LINK
Hi,
Is it possible to call methods on .aspx.cs and .ascx.cs pages rather than only on .asmx.cs ?
Thank you,
Steve.
mhawley
Participant
1314 Points
230 Posts
Re: Calling methods on aspx and ascx pages ?
Oct 31, 2005 05:39 PM|LINK
Glav
Participant
1365 Points
270 Posts
ASPInsiders
MVP
Re: Calling methods on aspx and ascx pages ?
Nov 03, 2005 12:26 AM|LINK
Have you actually tried this and managed to get it to work?
I know the theory but even on simple methods I get an exception raised that suggests that the method call to the server is incorrect, even though I am using the PageMethods.{methodname} proxy that is generated. I was under the impression that this problem would be fixed in later builds that are released. Bertrand Leroy was unable to duplicate but mentions that it may be because he already has a later build with that fixed, but which has not been publicly released yet.
Have a look at this thread http://forums.asp.net/ShowPost.aspx?PageIndex=2&PostID=1072770#1072770 and go to Page2 at the very end (last 3 or so messages) and you will see what I mean.
Blog: http://weblogs.asp.net/pglavich