Link to home
Start Free TrialLog in
Avatar of EYoung
EYoungFlag for United States of America

asked on

How display login name on VB ASP page?

I have written an ASP page in VB.net (VS 2010) on which I want to display the name of the user who logs in.  The name needs to be in a certain place on the page.

In the Default.aspx.vb file I have the following:  Public mUserName As String = User.Identity.Name

Now I want to display this public variable (mUserName) on the Default.aspx page.  I have tried displaying the user's login name in an asp:label as shown below, but it errors out because "Text" attribute value is not enclosed in quotes.  Here is the code:

    <div style="position:absolute; top:82px; left:950px; z-index: 1; visibility:visible; height: 20px; width: 100px;">
        <asp:Label ID="UserName" Text=mUserName runat="server" />
    </div>

I am new to ASP.  Should I be doing this another way?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of himanshut
himanshut
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EYoung

ASKER

Yes, that does display the user login name.  I also see that I need to rebuild the code to remove any errors.  I guess rebuilding the code somehow links the Default.aspx with the code-behind.  That is different from a WinForm project.

Thank you for th quick answer.