This documentation is archived and is not being maintained.

LoginName.FormatString Property

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

Provides a format item string to display.

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

public virtual string FormatString { get; set; }
/** @property */
public String get_FormatString ()

/** @property */
public void set_FormatString (String value)

public function get FormatString () : String

public function set FormatString (value : String)

Property Value

A string containing format items for displaying the user's name. The default value is "{0}".

Exception typeCondition


The format string is not valid.

The FormatString property contains a standard text format string that displays the user's name on the Web page. The string "{0}" indicates where in the string the user's name is inserted. The following table describes the available property settings.

Property setting


Default ("{0}")

The user's name is displayed when the user is logged on; otherwise, nothing is displayed.


Same as default. To hide the control, set the Visible property to false.

"Welcome to my site, {0}."

Displays the string "Welcome to my site, username." when the user is logged in. When the user is not logged in, nothing is displayed.

"Welcome to my site."

When the FormatString property is set to a string, the string is displayed when the user is logged in. Because the string does not contain "{0}", the user's name is not displayed. When the user is not logged in, nothing is displayed.

The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.

The following code example shows how to use the FormatString property 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;

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

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