Declaring PageMethods within Custom Web Control

D

Damien

I have a server control which is used on various ASP.NET pages.
Within this control, I would like to use ASP.NET AJAX PageMethods to
update data on the control. The problem is, the PageMethod wrapper
that is typically generated when the WebMethod is included on a Page
isn't being created when the WebMethod is in the control. Here's a
sample of the code...

C#:
[WebMethod]
public static string GetGreeting()
{
return "Hello World";
}

When the WebMethod is declared in the Page class, I can access this
using PageMethods.GetGreeting(...); from my JavaScript. Now that I've
moved the declaration to the Web Control, PageMethod.GetGreeting(...);
causes an error since it's not declared.

Is there any way to get this work? Seems like there should be, I
can't imagine that I have to declare the WebMethod within the Page
only.

Thanks in advance for your help.
-Damien
 
G

gerry

yep - page methods can only exist on the page - frustrating isn't it ?
I gave up on pagemethods for this very reason and went to a 'local'
webservice.
add a .asmx to your site and use that instead of any pagemethods - makes
things simpler and and the rendered page a lot less cluttered.
 

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

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top