Solved

How display login name on VB ASP page?

Posted on 2011-03-01
2
695 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:EYoung
2 Comments
 
LVL 10

Accepted Solution

by:
himanshut earned 500 total points
ID: 35013066
Remove
<asp:Label ID="UserName" Text=mUserName runat="server" />

and  replace it with

<asp:Label ID="UserName" runat="server" Text=""></asp:Label>

in your Default.vb
  IN Page_Load
Label.Text = mUserName;

It will display the name once you build and debug the project/website



Cheers!
0
 
LVL 7

Author Comment

by:EYoung
ID: 35013134
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.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question