Use a [WebMethod] in a TemplateControl

Discussion in 'ASP .Net Web Controls' started by Larry Neylon, Sep 22, 2009.

  1. Larry Neylon

    Larry Neylon Guest

    Hi all,

    I want to be able to expose a [WebMethod] to a page when I add a Server
    Control to a page, but I've no idea how (or if) you can do this.

    In effect I want to be able to have:

    public class MyWebControl : TemplateControl

    {

    [WebMethod]

    public static string DoSomething()

    {

    .... process ajax call stuff


    }

    }

    Then when I add the control to a page I want have DoSomething() available to
    call via AJAX on the page. I've got this all working if I add the WebMethod
    directly to the page, I just need to move DoSomething into the Server
    Control rather than implement it in each page.

    Any ideas?

    Many Thanks.
     
    Larry Neylon, Sep 22, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. MattB
    Replies:
    0
    Views:
    1,628
    MattB
    Feb 2, 2006
  2. DC
    Replies:
    0
    Views:
    707
  3. Laurahn
    Replies:
    1
    Views:
    825
    Steven Cheng[MSFT]
    Jun 11, 2007
  4. Ron Vecchi

    TemplateControl??

    Ron Vecchi, Apr 14, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    203
  5. Daniel Barisch

    How to use own classes as WebMethod-Parameters?

    Daniel Barisch, Aug 19, 2003, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    152
    Simon Smith
    Sep 1, 2003
Loading...

Share This Page