Solved

How display login name on VB ASP page?

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

757 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

17 Experts available now in Live!

Get 1:1 Help Now