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. Advertisements

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 (here). After that, you can post your question and our members will help you out.