?
Solved

How display login name on VB ASP page?

Posted on 2011-03-01
2
Medium Priority
?
698 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
himanshut earned 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 21 hours left to enroll

777 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