UserValidatedEventArgs.UserName Property


Gets the user name of the validated user.

Namespace:   System.Web.ClientServices.Providers
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

public string UserName { get; }

Property Value

Type: System.String

The user name of the validated user.

The following example code demonstrates how to use this property to display the user name in the title bar of a form.

private ClientFormsAuthenticationMembershipProvider formsMembershipProvider =
private String appName = "ClientAppServicesDemo";

private void AttachUserValidatedEventHandler()
    formsMembershipProvider.UserValidated += 
        new EventHandler<UserValidatedEventArgs>(Form1_UserValidated);

private void Form1_UserValidated(object sender, UserValidatedEventArgs e)
    // Set the form's title bar to the application name and the user name.
    this.Text = String.Format("{0} ({1})", appName, e.UserName);

.NET Framework
Available since 3.5
Return to top