Login Constructor

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

Creates a new instance of the Login control.

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

'Declaration
Public Sub New
'Usage
Dim instance As New Login
public Login ()
public function Login ()

The Login constructor creates a new instance of the Login control that can be programmatically inserted into a Web page.

The following table shows the initial property values for a new instance of Login.

Property

Initial value

RememberMeSet

true

VisibleWhenLoggedIn

true

FailureAction

true

FailureText

"Your login attempt has failed. Please try again."

MembershipProvider

"Default"

Orientation

Vertical

PasswordLabelText

"Password:"

PasswordRequiredErrorMessage

"Password."

RememberMeSet

false

RememberMeText

"Remember me next time."

LoginButtonText

"Login"

TextLayout

TextOnLeft

TitleText

"Login"

UserNameLabelText

"User Name:"

UserNameRequiredErrorMessage

"User Name."

The following code example uses the Login constructor to create a new instance of the Login control and add that instance to the Controls collection of a PlaceHolder control.

<%@ Page Language="VB" %>
<%@ Import Namespace="System.ComponentModel" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<SCRIPT runat="server">
Function IsValidEmail(ByVal strIn As String) As Boolean
    ' Return true if strIn is in valid e-mail format.
    Return Regex.IsMatch(strIn, ("^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"))
End Function

Sub OnLoggingIn(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.LoginCancelEventArgs)

    Dim loginControl As Login

    loginControl = CType(PlaceHolder1.FindControl("loginControl"), Login)

    If Not IsValidEmail(loginControl.UserName) Then
        loginControl.InstructionText = "You must enter a valid e-mail address."
        e.Cancel = True
    Else
        loginControl.InstructionText = String.Empty
    End If
End Sub

Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    Dim loginControl As New Login

    loginControl.ID = "loginControl"

    loginControl.HelpPageText = "Help loggin in..."
    loginControl.HelpPageUrl = "help.aspx"

    loginControl.PasswordRecoveryText = "Forgot your password?"
    loginControl.PasswordRecoveryUrl = "getPass.aspx"

    AddHandler loginControl.LoggingIn, AddressOf OnLoggingIn

    PlaceHolder1.Controls.Add(loginControl)

End Sub
</SCRIPT>

<HTML>
    <BODY>
        <FORM runat="server">
            <asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
        </FORM>
    </BODY>
</HTML>

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

Community Additions

ADD
Show: