【发布时间】:2016-08-28 21:08:13
【问题描述】:
我在网页上有一些 Ajax,它将一些数据提供给服务器端 VB.Net 方法。一旦数据在服务器端方法中,我需要调用另一个服务器端方法来使用我刚刚收集的数据。这是一个非常简化的示例:
' This method gets the input from the Ajax code on the web page.
<System.Web.Services.WebMethod> _
Public Shared Sub GetAwesome(VBInputText As String)
Dim strTest As String = VBInputText
' Now that we have collected input from the user,
' we need to run a method that does a ton of other stuff.
DisplayAwesome(VBInputText)
End Sub
Protected Sub DisplayAwesome(AwesomeIn As String)
' The real app does a lot more than this. For this example, it
' just sets the text of a literal.
litAwesomeResult.Text = AwesomeIn
End Sub
当然,在上面的示例中,DisplayAwesome(VBInputText) 给了我“无法引用实例成员...”错误。那么,现在可以从Public Shared Sub GetAwesome 调用Protected Sub DisplayAwesome 了吗?我希望与这种解决方案保持密切联系,因为它可以很好地与应用程序配合使用,因为它已经由另一位同事编写。
【问题讨论】:
-
从
GetAwesome()的声明中删除了共享
标签: asp.net vb.net asp.net-ajax