【发布时间】:2013-10-13 09:29:48
【问题描述】:
我有以下网络方法
<System.Web.Services.WebMethod()> Public Shared Function NewMethod(ByVal str1 As String) As String
LoadBlock(str1)
Return "Success"
End Function
以及以下步骤
Public Sub LoadBlock(ByVal AA As Integer)
panAway.Visible = False '<--ASP panel control
lblHome.Visible = False '<--ASP label control
End
这会引发以下错误
Cannot refer to an instance member of a class from within a shared method or
shared member initializer without an explicit instance of the class.
我知道我收到以下错误是因为我没有将 LoadBlock 设置为共享
但是如果我这样做,我的程序中的所有控件......都会引发上述错误
对此我有什么办法吗?
【问题讨论】:
-
仅供参考,
WebMethod不是“引发”错误——这是一个简单的编译器错误,并且已经告诉你需要知道的内容——假设你知道什么是“实例方法”和“共享”方法”的意思。
标签: asp.net vb.net asmx webmethod pagemethods