Avatar of vraag
vraag

asked on 

Properties vb.net

Hello,

I did convert a piece of C# source to VB.net
public class properties
{
    private static HttpContext Context { get { return System.Web.HttpContext.Current; } }
    private static HttpSessionState Session { get { return Context.Session; } }

    // Get settings from session
    public static string loggedIn { get { return (Session["Properties.loggedIn"] ?? String.Empty).ToString(); } set { Session["Properties.loggedIn"] = value; } }
    public static string userId { get { return (Session["Properties.userId"] ?? String.Empty).ToString(); } set { Session["Properties.userId"] = value; } }
}

Open in new window


to:
Public Class properties
    Private Shared ReadOnly Property Context() As HttpContext
        Get
            Return System.Web.HttpContext.Current
        End Get
    End Property
    Private Shared ReadOnly Property Session() As HttpSessionState
        Get
            Return Context.Session
        End Get
    End Property

    ' Get settings from session
    Public Shared Property loggedIn() As String
        Get
            Return (If(Session("Properties.loggedIn"), String.Empty)).ToString()
        End Get
        Set(ByVal value As String)
            Session("Properties.loggedIn") = value
        End Set
    End Property
    Public Shared Property userId() As String
        Get
            Return (If(Session("Properties.userId"), String.Empty)).ToString()
        End Get
        Set(ByVal value As String)
            Session("Properties.userId") = value
        End Set
    End Property


End Class

Open in new window


If i run this i get the following error:
Compilation error

Error message from compiler: BC30201: Expressie expected.

Error in source:

 

Regel 25:     Public Shared Property loggedIn() As String
Regel 26:         Get
Regel 27:             Return (If(Session("Properties.loggedIn"), String.Empty)).ToString()
Regel 28:         End Get
Regel 29:         Set(ByVal value As String)
 

Does any one know what goes wrong?

Thanks in advance.
.NET ProgrammingEditors IDEs

Avatar of undefined
Last Comment
vraag
Avatar of dj_alik
dj_alik

May be you are using in aspx some of this properties?
Databinding syntax in the markup.
Avatar of vraag
vraag

ASKER

Yes i need those properties to determine if someone has logged in or not.
Avatar of dj_alik
dj_alik

please check your binding syntax in aspx
Avatar of vraag
vraag

ASKER

Hi dj_Alik,

Thanks for taking the affort to help me out here.

Is this what you mean?
If properties.loggedIn = "true" Then
...
        Else
...
        End If

Open in new window

Avatar of dj_alik
dj_alik

please post your aspx page that is using those properties
Avatar of dj_alik
dj_alik

click on Error message from compiler: BC30201: Expressie expected.
in VS error windows may be you will get right to the error  code on editor.
Avatar of vraag
vraag

ASKER

Avatar of vraag
vraag

ASKER

ASKER CERTIFIED SOLUTION
Avatar of vraag
vraag

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of dj_alik
dj_alik

You are getting the error message because the code is in Visual basic and whenever there is any continuous in the code
try to add then in if
If  X Then
    ...
 End if



 
Avatar of vraag
vraag

ASKER

No solution found
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo