How to assign a text to LoginName control?

Last post 07-04-2009 8:45 PM by bhadelia.imran. 2 replies.

Sort Posts:

  • How to assign a text to LoginName control?

    07-04-2009, 4:46 AM

    Hi, I've put a "LoginName" control to my web form. I want to change the text that it displays to the user name of the user which is in a session variable "user". I dont use the Membership class. How do i change the text of the LoginName control to user's username?

     

    cheers

  • Re: How to assign a text to LoginName control?

    07-04-2009, 7:12 AM
    Answer

    If you are not using the membership classes then there isn't any point of using LoginName control.

    Instead you use a simple Label control and on "Successful login" change it's Text property accordingly like:

    txtLoginName.Text="Welcome,"+Convert.ToStriong(Session["user"]);

    Good Luck.
    Saurabh Nijhawan(B.Tech. CSE,GGSIPU,New Delhi)
    Application Architect, Eminent Solutions, New Delhi.
    Freelancer | Teacher
    Remember to click "Mark as Answer" on the post, if it helped you.
    ASP.NET Weblog
    http://www.saurabhnijhawan.com
    Learning Made Easy

  • Re: How to assign a text to LoginName control?

    07-04-2009, 8:45 PM
    • Contributor
      2,861 point Contributor
    • bhadelia.imran
    • Member since 08-04-2008, 2:59 AM
    • India
    • Posts 477

    nijhawan.saurabh:

    If you are not using the membership classes then there isn't any point of using LoginName control.

    There is no relation between LoginName control and Membership, Memberhsip exposed few functinality for Developer, making their life easier in common functoin and LoginName.

    If you want to use LoginName control, then you must use Forms Based Authentication, the LoginName displays the value of the System.Web.UI.Page.User.Identity.Name property which is get filled by FormsAuthentication.SetAuthCookie or once user get logged in create GenericIdentity and assign to System.Web.UI.Page.User.Identity. So you dont need Session to store that infor, it will be added in Identity.

    Hope this helps

    Imran
    [MCTS]
    Born to fly High
    http://knowledgebaseworld.blogspot.com/
Page 1 of 1 (3 items)