aspxtreme

Login Class

System.Web.UI.WebControls Namespace


.NET Framework version 2.0

Provides user interface ( UI ) elements for logging in to a Web site.

Login Class Members

Collapse   Constructors

Visibility Constructor Parameters
public Login ( )

Collapse   Fields

Visibility Name Type
public static LoginButtonCommandName String

Collapse   Properties

Visibility Name Value Type Accessibility
public BorderPadding Int32 [ Get , Set ]
public CheckBoxStyle TableItemStyle [ Get ]
public CreateUserIconUrl String [ Get , Set ]
public CreateUserText String [ Get , Set ]
public CreateUserUrl String [ Get , Set ]
public DestinationPageUrl String [ Get , Set ]
public DisplayRememberMe Boolean [ Get , Set ]
public FailureAction LoginFailureAction [ Get , Set ]
public FailureText String [ Get , Set ]
public FailureTextStyle TableItemStyle [ Get ]
public HelpPageIconUrl String [ Get , Set ]
public HelpPageText String [ Get , Set ]
public HelpPageUrl String [ Get , Set ]
public HyperLinkStyle TableItemStyle [ Get ]
public InstructionText String [ Get , Set ]
public InstructionTextStyle TableItemStyle [ Get ]
public LabelStyle TableItemStyle [ Get ]
public LayoutTemplate ITemplate [ Get , Set ]
public LoginButtonImageUrl String [ Get , Set ]
public LoginButtonStyle Style [ Get ]
public LoginButtonText String [ Get , Set ]
public LoginButtonType ButtonType [ Get , Set ]
public MembershipProvider String [ Get , Set ]
public Orientation Orientation [ Get , Set ]
public Password String [ Get ]
public PasswordLabelText String [ Get , Set ]
public PasswordRecoveryIconUrl String [ Get , Set ]
public PasswordRecoveryText String [ Get , Set ]
public PasswordRecoveryUrl String [ Get , Set ]
public PasswordRequiredErrorMessage String [ Get , Set ]
public RememberMeSet Boolean [ Get , Set ]
public RememberMeText String [ Get , Set ]
public TextBoxStyle Style [ Get ]
public TextLayout LoginTextLayout [ Get , Set ]
public TitleText String [ Get , Set ]
public TitleTextStyle TableItemStyle [ Get ]
public UserName String [ Get , Set ]
public UserNameLabelText String [ Get , Set ]
public UserNameRequiredErrorMessage String [ Get , Set ]
public ValidatorTextStyle Style [ Get ]
public VisibleWhenLoggedIn Boolean [ Get , Set ]

Collapse   Methods

Visibility Name Parameters Return Type
protected LoadViewState ( Object savedState ) Void
protected OnAuthenticate ( AuthenticateEventArgs e ) Void
protected OnBubbleEvent ( Object source , EventArgs e ) Boolean
protected OnLoggedIn ( EventArgs e ) Void
protected OnLoggingIn ( LoginCancelEventArgs e ) Void
protected OnLoginError ( EventArgs e ) Void
protected SaveViewState ( ) Object
protected SetDesignModeState ( IDictionary data ) Void
protected TrackViewState ( ) Void

Collapse   Events

Remarks

The Login control is a composite control that provides all the common UI elements needed to authenticate a user on a Web site. The following three elements are required for all login scenarios:

  • A unique user name to identify the user.
  • A password to verify the identity of the user.
  • A login button to send the login information to the server.

The Login control also provides the following optional UI elements that support additional functions:

  • A link for a password reminder.
  • A Remember Me checkbox for retaining the login information between sessions.
  • A Help link for users who are having trouble logging in.
  • A Register New User link that redirects users to a registration page.
  • Instruction text that appears on the login form.
  • Custom error text that appears when the user clicks the login button without filling in the user name or password fields.
  • Custom error text that appears if the login fails.
  • A custom action that occurs when login succeeds.
  • A way to hide the login control if the user is already logged in to the site.

For a table showing which controls are required and which are optional, see LayoutTemplate property.

NOTE: Accepting user input is a potential security threat. Malicious users can send data that is intended to expose vulnerabilities or run programs that try generated passwords. To improve security when working with user input, you should use the validation features of your control and secure any data providers that are configured for your control. For more information, see Securing Login Controls, Basic Security Practices for Web Applications, and Securing Membership.

The Login control uses a membership provider to obtain user credentials. Unless you specify otherwise, the Login control uses the default membership provider defined in the Web.config file. To specify a different provider, set the MembershipProvider property to one of the membership provider names defined in your application's Web.config file. For more information, see Membership Providers.

If you want to use a custom authentication service, you can use the OnAuthenticate method to call the service.

Styles and Templates

The appearance of the Login control is fully customizable through templates and style settings. All UI text messages are also customizable through properties of the Login class. The default interface text is automatically localized based on the locale setting on the server.

When the CreateUserWizard control is not customized with templates, the AccessKey property of the CreateUserWizard control applies to the first text box in the control and the TabIndex property, which is applied to all text boxes of the control. If the Login control is customized with templates, then the AccessKey property and the TabIndex property are ignored. In this case, set the AccessKey property and the TabIndex property of each template child control directly.

Login control properties represented by text boxes, such as UserName and Password, are accessible during all phases of the page life cycle. The control will pick up any changes made by the end user by means of the TextChanged event triggered by the textboxes.

NOTE: If you embed the Login control in a WizardStep object, explicitly set the ActiveStepIndex property in a Page_Load event handler if the user is authenticated. The Wizard control does not automatically advance to the next WizardStep object in this scenario.

The following table lists the Login control style properties and explains which UI element each style property affects. For a list of which properties each style applies to, see the documentation for the individual style properties.

Style property UI element affected
BorderPadding The space between the control contents and the control's border.
CheckBoxStyle Remember Me checkbox.
FailureTextStyle Login failure text.
InstructionTextStyle Instructional text on the page that tells users how to use the control.
LabelStyle Labels for all input fields, such as text boxes.
TextBoxStyle Text entry input fields.
TitleTextStyle Title text.
ValidatorTextStyle Text displayed to the user when a login attempt is unsuccessful due to validation errors.
HyperLinkStyle Links to other pages.
LoginButtonStyle Login button.

Validation Groupings

The UserName and Password properties have RequiredFieldValidator controls associated with them to prevent users from submitting the page without providing required information.

The Login control uses a validation group so that other fields on the same page as the Login control can be validated separately. By default, the ID property of the Login control is used as the name of the validation group. For example, a Login control with the ID "Login1" will use a validation group name of "Login1". If you want to set the validation group that the Login control is part of, you must template the control and change the validation group name.

For examples illustrating use of this control, see the individual member types of this class. For syntax information, see Login in ASP.NET Syntax for Web Controls.

See Also

ASP.NET Login Controls   Login Web Server Control



Books and more ...


Suggested Reading

Need a break ?



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme