How to create Login page in asp.net

Login Web Server Control
in an asp.net application we can create an user login page by using Login web server control. this Login control display a user interface for user authentication. Login control render two TextBoxes to input username and password. it also display a CheckBox that allow users to indicate whether they want the server store their identity for next visit. it allow users to automatically authenticated for next visit.

the Login control have many useful built in properties to customize it. we can change the default look and feel of login page by using Login control's BackColor, BorderColor, BorderWidth, BorderStyle, CheckBoxStyle, CreateUserIconUrl, CreateUserText, CreateUserUrl, CssClass, Font, ForeColor, FailureTextStyle, Height, HelpPageIconUrl, LayoutTemplate, TextBoxStyle, TitleTextStyle, LabelStyle, InstructionTextStyle, HyperLinkStyle, LoginButtonStyle, ValidatorTextStyle, BorderPadding and many more properties. the Login control is fully customizable through templates and style settings.

this Login control is a composite control that render all common user interface elements needed to authenticate a user in an asp.net application (web site).

Login control's CreateUserText property allow us to set the text of a link to a registration page for new users. CreateUserUrl property set an url for new user registration page. DestinationPageUrl set an url of the page displayed to the user when a login successful.

DisplayRememberMe allow us to show or hide Remember Me checkbox from login page. FailureText property allow us to set the text displayed when a login attempt fail. HelpPageUrl property set an url for login help page. InstructionText property set login instruction text for user.

we also can change the default text of login control's elements by properties settings such as title text, remember me text, password label text etc.

the following asp.net example code demonstrate us how can we create an user login page using Login server control in an asp.net application.
Login.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Login control Example: how to create Login page in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Login ID="Login1" runat="server"></asp:Login>
    </div>
    </form>
</body>
</html>
Default.aspx

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Using LoginStatus and LoginName Control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h1>Home page</h1>
        <asp:LoginStatus ID="LoginStatus1" runat="server" />
        <br /><br />
        <asp:LoginName ID="LoginName1" runat="server" FormatString="{0} logged in." Font-Size="Larger" ForeColor="Crimson" />
    </div>
    </form>
</body>
</html>
Related asp.net examples