|
|
|
start date: Fri, 10 Aug 2007 08:45:46 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Damien
|
|
2
gerry am
|
Declaring PageMethods within Custom Web Control
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
Date:Fri, 10 Aug 2007 08:45:46 -0700
Author:
|
Re: Declaring PageMethods within Custom Web Control
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.
"Damien" wrote in message
news:1186760746.517111.236260@z24g2000prh.googlegroups.com...
>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
>
Date:Wed, 15 Aug 2007 14:27:02 -0400
Author:
|
|
|