DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
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:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us