if statement based on UserName, .NET vb
-
14-11-2019 - |
Question
within my asp.net vb web application i have a form that displays data in various text fields. I want to place an if statement on the following code that will check if the logged in username is "TUSER", if so, place "TEST2" into the text field. For all other users, place "TEST" into the text field.
txtReportTo.Text = _
"TEST"
Im currently using aspnet membership to manage users. any code guidance would be great. thanks.
Solution
Dim user = Membership.GetUser()
If user IsNot Nothing Then
If user.UserName = "TUSER" Then
txtReportTo.Text = "TEST2"
Else
txtReportTo.Text = "TEST"
End If
End If
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow