Priyank Patel
Priyank Patel

Reputation: 6996

Displaying the text of <a> element from database in Asp.Net

I am using Asp.Net/C# in my application.I have a menu on my master page which displays all pre-defined menu items(static way) like

  1. Home
  2. Contact Us
  3. About Us

What I would like to accomplish is, I want the text of <a> element to be displayed from database , which will be the name of the logged-in user.

Can anybody suggest me as to how I can go about doing this. Thanks

Upvotes: 0

Views: 159

Answers (2)

skhurams
skhurams

Reputation: 2145

if i understand correctly if you want username in the menu and Concatinate that menu with userName then just store @@username in database with menu and when loading replace @@username with the user

using String.replace("@@username",strUserName)

Upvotes: 0

Royi Namir
Royi Namir

Reputation: 148624

   <ul>
    <li>
        <a>Home</a>
    </li>
    <li>
        <a>Contact Us</a>
    </li>
    <li>
        <a><%=Request.LogonUserIdentity.Name %></a>
    </li>
  </ul>

however - you need windows authentications in order to see the real logged on user - otherwise youll see the AppPool user.

p.s. if youre under binding context : use <%#

Upvotes: 1

Related Questions