I have a public shared function and I’m trying to access the values of a text box and a session variable.
I’m getting the error “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.”
Is there any way I can get to the values in the textboxes or session variables from within the method?
Thanks,
<WebMethod()> _
Public Shared Function savenote() As String
Dim newnote As New note()
newnote.callID = txtRef.Text
newnote.LoggedBy = Session("user_id")
newnote.Note = txtNote.Text
newnote.Create()
Return 1
End Function
You could reference session by calling the static
HttpContext.Current.Session. Typically with web methods you would pass the value from the TextBox in.MSDN: http://msdn.microsoft.com/en-us/library/63zsebh3.aspx