ASP.Net 2.0 LoginName Control

Updated on 09 Aug 2012,
Published on 24 May 2008

LoginName control displays the UserName of the authenticated user currently logged into the web site. LoginName also uses the sql membership provider to retrieve the authenticated username. It uses the Page.User.Identity.Name to get the UserName of the currently logged in user. 

If the user is not logged in then LoginName control does not render on web page and does not hold any space block on the page.

LoginName Control FormatString

FormatString property of the LoginName control enables you to customize the string and UserName that can be displayed in the control. For example if you want to display the greeting message followed by UserName then you can set the FormatString value = Hi {0}!

Above value for FormatString will display Hi followed by UserName of the logged in user.

{0} is automatically replaces by the username when LoginName control is rendered on the page if any user is currently logged in.

Cotninue to next tutorial: ASP.Net 2.0 LoginStatus Control to learn how to display the login status of the logged in user.

0 Responses to "ASP.Net 2.0 LoginName Control"
Leave a Comment
* required
* required
* will not be published
* optional
* hint: http://www.example.com
  • Subscribe via Email
  • HIRE EzineASP.Net Developers