using web methods with master pages

后端 未结 3 1034
春和景丽
春和景丽 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:56

    How about putting the webmethod in a base class?

    public class WebMethodBase : Page
    {
         _
        Public Shared Function GetDate() As String
            Return DateTime.Now.ToString()
        End Function
    }
    

    Then inherit this class from those pages you want to expose the webmethod.

    Forgive me for mixed C# and VB, i am not familiar with VB syntax.

提交回复
热议问题