using web methods with master pages

后端 未结 3 1015
春和景丽
春和景丽 2021-01-05 01:24

I\'ve got a function on all pages in my site which is located in my master page and I want it to run from some jQuery Ajax method.

I\'ve got some code like this at t

3条回答
  •  臣服心动
    2021-01-05 01:46

    Your webmethod code cannot reside in the codebehind for your master page.

    I've found it easier to include an actual web service or WCF service in my project for things that I will need to call from multiple pages.

    EDIT :

    To add a WCF Service to your project:

    1. right click the project
    2. select [WCF Service] and give it a name (ie. Agent.svc)
    3. set up the service (see http://www.codeproject.com/KB/aspnet/jQuery_To_WCF.aspx)

    More than a few examples here on the Stackoverflow...

    Hope that helps.

提交回复
热议问题