locked
can't get Session variable to work RRS feed

  • Question

  • User2055999601 posted

    Hello,

    I'm experimenting with the Session variable in VB.NET (and ASP.NET). I've got a login page here: http://www.shahspace.com/autobody/index.aspx and it contains this snippet of code:


    Sub Authenticate()

     Dim username As String
     Dim password As String
     Dim i As Integer

     For i = DS.Tables(0).Rows.Count-1 to 0 Step -1
      username = DS.Tables(0).Rows(i).Item("username")
      If username = username_textbox.Text.Trim() Then
       password = DS.Tables(0).Rows(i).Item("password")
       If password = password_textbox.Text Then
        Session["username"] = username
        Session["password"] = password
        Response.Redirect("access_granted.html")
       Else Exit For
       End If
      End If
     Next

     feedback_label.Text = "Access denied"

    End Sub

    But if you go to the page you see that the line that assigns username to Session["username"] is resulting in an error: BC30545: Property access must assign to the property or use its value.

    What does this mean?

    Monday, February 14, 2011 4:36 PM

Answers

  • User-1952482173 posted

    Check VB.NET syntax. Session["username"] is c# language. I think VB uses Session("username") 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 14, 2011 4:52 PM

All replies

  • User-1952482173 posted

    Check VB.NET syntax. Session["username"] is c# language. I think VB uses Session("username") 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 14, 2011 4:52 PM
  • User-1708821649 posted

    what exactly are you trying to do?

    Monday, February 14, 2011 4:53 PM
  • User2055999601 posted

    Check VB.NET syntax. Session["username"] is c# language. I think VB uses Session("username") 

     

    You're right. I was following an online tutorial that gave examples in both VB and C#. I guess I used the wrong example.

    what exactly are you trying to do?

    I'm experimenting with the Session variable purely for learning purposes.

    Tuesday, February 15, 2011 12:02 PM