Click here to Skip to main content
15,886,110 members
Articles / Web Development / XHTML

Fully configured ASP.NET Membership Website Template

Rate me:
Please Sign up or sign in to vote.
4.89/5 (18 votes)
7 Jul 2009CPOL4 min read 165K   8.3K   119  
A pre-configured ASP.NET website containing a Master page, error handling, login / logout, and other boilerplate new project code.
<%@ Page Title="PathfinderTools - Login" Language="C#" MasterPageFile="~/DefaultMaster.master"
    AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphBody" runat="Server">
    <asp:Panel ID="pnlLogin" runat="server" DefaultButton="btnLogin">
        <table border="0" cellpadding="3" cellspacing="0" align="center" width="400" class="Border">
            <tr>
                <td colspan="2" class="HeaderCell">
                    Login
                </td>
            </tr>
            <tr>
                <td width="85">
                    <asp:Label ID="lblUserName" CssClass="lbl" runat="server" Text="User Name:" AssociatedControlID="txtUserName" />
                </td>
                <td>
                    <asp:TextBox ID="txtUserName" runat="server" Width="250px" MaxLength="50" />&nbsp;
                    <asp:RequiredFieldValidator ID="rfvUserName" runat="server" ErrorMessage="* Required Field"
                        CssClass="Message" ForeColor="" Display="Dynamic" ValidationGroup="Login" ControlToValidate="txtUserName" />
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblPassword" CssClass="lbl" runat="server" Text="Password:" AssociatedControlID="txtPassword" />
                </td>
                <td>
                    <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="250px" MaxLength="50" />&nbsp;
                    <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ErrorMessage="* Required Field"
                        CssClass="Message" ForeColor="" Display="Dynamic" ValidationGroup="Login" ControlToValidate="txtPassword" />
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <asp:LinkButton ID="lnkForgot" runat="server" OnClick="lnkForgot_Click" CausesValidation="false">Forgot your Password?</asp:LinkButton>
                </td>
            </tr>
            <tr>
                <td align="center" colspan="2">
                    <asp:Button ID="btnLogin" runat="server" OnClick="btnLogin_Click" Text="Login" ValidationGroup="Login" />&nbsp;
                    <asp:Button ID="btnClear" runat="server" CausesValidation="false" OnClick="btnClear_Click"
                        Text="Clear" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlReset" runat="server" Visible="false" DefaultButton="btnResetPassword">
        <table border="0" cellpadding="3" cellspacing="0" align="center" width="400" class="Border">
            <tr>
                <td colspan="2" class="HeaderCell">
                    Reset Password
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="Label1" runat="server" CssClass="lbl" Text="New Password:" EnableViewState="false"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtPasswordReset" runat="server" TextMode="Password" Width="250px"
                        MaxLength="50" />&nbsp;
                    <asp:RequiredFieldValidator ID="rfvPasswordReset" runat="server" ControlToValidate="txtPasswordReset"
                        CssClass="Message" Display="Dynamic" ErrorMessage="* Required Field" ForeColor="" />&nbsp;
                    <asp:RegularExpressionValidator ID="revPasswordReset" runat="server" CssClass="Message"
                        Display="Dynamic" ErrorMessage='Your password must be between 8 and 15 characters long, contain a lower case letter, a capital letter, one number, and contain one of the following symbols: !, @, #, $, %, ^, &, *, (, ), _ +'
                        ForeColor="" ControlToValidate="txtPasswordReset"></asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td valign="top" width="85">
                    <asp:Label ID="Label2" runat="server" CssClass="lbl" Text="Confirm Password:" EnableViewState="false"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtConfirmPasswordReset" runat="server" TextMode="Password" Width="250px"
                        MaxLength="50"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtConfirmPasswordReset"
                        CssClass="Message" Display="Dynamic" ErrorMessage="* Required Field" ForeColor=""></asp:RequiredFieldValidator>
                    <asp:CompareValidator ID="cvPasswordReset" runat="server" ControlToCompare="txtPasswordReset"
                        ControlToValidate="txtConfirmPasswordReset" CssClass="Message" ErrorMessage="New Passwords Do Not Match"
                        ForeColor="" Display="Dynamic"></asp:CompareValidator>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <asp:Button ID="btnResetPassword" runat="server" Text="Reset Password" OnClick="btnResetPassword_Click" />
                    &nbsp;<asp:Button ID="btnResetCancel" runat="server" CausesValidation="false" 
                        OnClick="btnCancel_Click" Text="Cancel" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlForgot" runat="server" Visible="false" DefaultButton="btnForgotPassword">
        <table border="0" class="Border" cellpadding="3" cellspacing="0" width="400" align="center">
            <tr>
                <td class="HeaderCell" colspan="2">
                    Forgot your password
                </td>
            </tr>
            <tr>
                <td width="85">
                    <asp:Label ID="Label3" runat="server" CssClass="lbl" Text="Username:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtForgotPasswordUserName" runat="server" Width="250px" MaxLength="50"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtForgotPasswordUserName"
                        CssClass="Message" Display="Dynamic" ErrorMessage="* Required Field" ForeColor=""></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <asp:Button ID="btnForgotPassword" runat="server" Text="Submit" OnClick="btnForgotPassword_Click" />&nbsp;
                    <asp:Button ID="btnForgotCancel" runat="server" Text="Cancel" OnClick="btnCancel_Click"
                        CausesValidation="false" />
                </td>
            </tr>
        </table>
    </asp:Panel>
    <asp:Panel ID="pnlAnwser" runat="server" Visible="false" DefaultButton="btnCheckAnswer">
        <table border="0" class="Border" cellpadding="3" cellspacing="0" width="400" align="center">
            <tr>
                <td class="HeaderCell" colspan="2">
                    &nbsp; Please Answer the following question.
                </td>
            </tr>
            <tr>
                <td width="85">
                    <asp:Label ID="Label4" runat="server" CssClass="lbl" Text="Question:"></asp:Label>
                </td>
                <td>
                    <asp:Label ID="lblQ" runat="server" /><asp:Label ID="LblA" runat="server" Visible="false" />
                </td>
            </tr>
            <tr>
                <td width="85">
                    <asp:Label ID="Label5" runat="server" CssClass="lbl" Text="Answer:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="txtAnswer" runat="server" Width="250px" MaxLength="50"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <asp:Button ID="btnCheckAnswer" runat="server" Text="Submit" OnClick="btnCheckAnswer_Click" />&nbsp;
                    <asp:Button ID="btnAnswerCancel" runat="server" Text="Cancel" 
                        OnClick="btnCancel_Click" />
                </td>
            </tr>
        </table>
    </asp:Panel>
</asp:Content>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Harland Financial Solutions
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions