Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Display username in all pages after logging in

Display username in all pages after logging in

Scheduled Pinned Locked Moved ASP.NET
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yorockk
    wrote on last edited by
    #1

    I want to display the username once the user logs in successfully. iam using loginview control in the master page but how to insert the username in the logged in template of the loginview control.. everytime by default it displays the value in the logged in template instead of anonymous template.. plzz suggest some solution

    A 1 Reply Last reply
    0
    • Y yorockk

      I want to display the username once the user logs in successfully. iam using loginview control in the master page but how to insert the username in the logged in template of the loginview control.. everytime by default it displays the value in the logged in template instead of anonymous template.. plzz suggest some solution

      A Offline
      A Offline
      anilpal
      wrote on last edited by
      #2

      Hi, In loggin page u can do below code to assign the user name in either way: Use label in master page: 1. Session["UserName"]="Anil"; //Set string str =Session["UserName"].ToString(); /Get Or 2. Context.User.Identity.Name ="Anil" // Set string str=Context.User.Identity.Name ;//Get

      Regards Anil Pal

      Y 1 Reply Last reply
      0
      • A anilpal

        Hi, In loggin page u can do below code to assign the user name in either way: Use label in master page: 1. Session["UserName"]="Anil"; //Set string str =Session["UserName"].ToString(); /Get Or 2. Context.User.Identity.Name ="Anil" // Set string str=Context.User.Identity.Name ;//Get

        Regards Anil Pal

        Y Offline
        Y Offline
        yorockk
        wrote on last edited by
        #3

        with the following code iam tryin to access label control of the master page and modify it: 1. Dim mplabel As New Label 2. mplabel = CType(PreviousPage.Master.FindControl("Label1"), _ Label) 3. If Not mplabel Is Nothing Then 4. mplabel.Text = "welcome" 5. End If but still iam gettin an nullreference exception in line 2:object reference not set to an instance of an object.

        modified on Friday, April 3, 2009 4:21 PM

        A 1 Reply Last reply
        0
        • Y yorockk

          with the following code iam tryin to access label control of the master page and modify it: 1. Dim mplabel As New Label 2. mplabel = CType(PreviousPage.Master.FindControl("Label1"), _ Label) 3. If Not mplabel Is Nothing Then 4. mplabel.Text = "welcome" 5. End If but still iam gettin an nullreference exception in line 2:object reference not set to an instance of an object.

          modified on Friday, April 3, 2009 4:21 PM

          A Offline
          A Offline
          anilpal
          wrote on last edited by
          #4

          HI, Please use below code to access the control of the master page. If it is outside the contentplace holder(Which ofcourse). Page.Master.FindControl("Label1")

          Regards Anil Pal

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups