0

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

7
  • so how does the first paragraph releated to question ? Commented Apr 23, 2012 at 12:16
  • by static way you mean hard-coded. your question is too broad, read more regarding database integration Commented Apr 23, 2012 at 12:16
  • @RoyiNamir I didnot get you , why is it irrelevent. Commented Apr 23, 2012 at 12:18
  • @freebird you have a menu. and beside that - you want the logged on user into an <a> element. correct ? Commented Apr 23, 2012 at 12:20
  • @RoyiNamir I may have not explained my requirement properly but I would like to achieve something like this Home Contact Us About Us RoyiNamir , the users name will be to right of the menu.I hope it makes sense Commented Apr 23, 2012 at 12:21

2 Answers 2

1
   <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 <%#

Sign up to request clarification or add additional context in comments.

3 Comments

,I am using Forms Authentication , how do I do it then
try that or HttpContext.Current.User.Identity
HttpContext.Current.User.Identity worked for me , similarly can I display a column from database table inside anchor tag , is it possible
0

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.