Export (0) Print
Expand All
1 out of 8 rated this helpful - Rate this topic

LoginName Class

Note: This class is new in the .NET Framework version 2.0.

Displays the value of the System.Web.UI.Page.User.Identity.Name property.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

[BindableAttribute(false)] 
public class LoginName : WebControl
/** @attribute BindableAttribute(false) */ 
public class LoginName extends WebControl
BindableAttribute(false) 
public class LoginName extends WebControl

By default, the LoginName control displays the name contained in the User property of the Page class. If the System.Web.UI.Page.User.Identity.Name property is empty, the control is not rendered.

To change the text displayed by the LoginName control, set the FormatString property.

NoteNote

The LoginName control cannot be used outside the <form> tag on a Web page. Specifically, the LoginName cannot be used to put the user's name in the title of a page.

Accessibility

The markup rendered by default for this control might not conform to accessibility standards such as the Web Content Accessibility Guidelines 1.0 (WCAG) priority 1 guidelines. For details about accessibility support for this control, see ASP.NET Controls and Accessibility.

TopicLocation
How to: Display the Name of the Current UserBuilding ASP .NET Web Applications
How to: Display the Name of the Current UserBuilding ASP .NET Web Applications
Walkthrough: Managing Web Site Users with RolesBuilding ASP .NET Web Applications in Visual Studio

The following code example shows how to use the LoginName class on a page. Clicking the button changes the display format.

<%@ Page Language="C#" autoeventwireup="False" %>
<script runat="server">

    void Button1_Click(Object sender, EventArgs e) {
        LoginName1.FormatString = "Welcome to our Web site, {0}";
         Button1.Visible = false;
    }

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:LoginName id="LoginName1" runat="server" 
               FormatString ="Welcome, {0}" />
        </p>
        <p>
            <asp:Button id="Button1" onclick="Button1_Click" runat="server" 
               Text="Change Format" />
        </p>
    </form>
</body>
</html>

System.Object
   System.Web.UI.Control
     System.Web.UI.WebControls.WebControl
      System.Web.UI.WebControls.LoginName
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.