Solved

How display login name on VB ASP page?

Posted on 2011-03-01
2
691 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb.net 2 37
consuming an asmx web service in winforms application 3 24
Change Format on Data when exporting to Excel 4 23
IIS Authorization for Web Service 2 22
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…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now