ProTech's home page

ProTech-Online.com

Microsoft C# ASPX code example create user accounts webpage.

<%@ Page Title="SANS Secure Code Exercise" Language="VB" MasterPageFile="~/sans.master" AutoEventWireup="false" CodeFile="CreatingUserAccounts.aspx.vb" Inherits="admin_CreatingUserAccounts" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
        ContinueDestinationPageUrl="~/admin/CreatingUserAccounts.aspx"
        LoginCreatedUser="False">
        <StepNavigationTemplate>
            <asp:Button ID="StepPreviousButton" runat="server" CausesValidation="False"
                CommandName="MovePrevious" Text="Previous" />
            <asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext"
                Text="Next" />
        </StepNavigationTemplate>
    <WizardSteps>
        <asp:CreateUserWizardStep ID="CreateUser" runat="server" >
            <ContentTemplate>
                <table border="0">
                    <tr>
                        <td align="center" colspan="2">
                            Create New User</td>
                    </tr>
                    <tr><td colspan="2"></td></tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
                                ControlToValidate="UserName" ErrorMessage="User Name is required."
                                ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server"
                                ControlToValidate="UserName" ErrorMessage="Bad Chars"
                                ValidationExpression="^[^%'\<\>&quot;]*$"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Password:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
                                ControlToValidate="Password" ErrorMessage="Password is required."
                                ToolTip="Password is required." ValidationGroup="CreateUserWizard1" >*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                                ControlToValidate="Password" ErrorMessage="Bad Chars"
                                ValidationExpression="^[^%'\<\>&quot;]*$"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="ConfirmPasswordLabel" runat="server"
                                AssociatedControlID="ConfirmPassword">Confirm Password:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server"
                                ControlToValidate="ConfirmPassword"
                                ErrorMessage="Confirm Password is required."
                                ToolTip="Confirm Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server"
                                ControlToValidate="ConfirmPassword" ErrorMessage="Bad Chars"
                                ValidationExpression="^[^%'\<\>&quot;]*$"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">
                            <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">E-mail:</asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="Email" runat="server"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="EmailRequired" runat="server"
                                ControlToValidate="Email" ErrorMessage="E-mail is required."
                                ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server"
                                ControlToValidate="Email" ErrorMessage="Bad Chars"
                                ValidationExpression="^[^%'\<\>&quot;]*$"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr><td style="text-align: right">
                        <asp:Label ID="Label3" runat="server" Text="Role:"></asp:Label>
                        </td>
                        <td>
                            <asp:DropDownList ID="UserRole" runat="server" DataSourceID="SqlDataSource1"
                                DataTextField="RoleName" DataValueField="RoleName">
                            </asp:DropDownList>
                            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                                ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
                                SelectCommand="SELECT [RoleName] FROM [vw_aspnet_Roles]">
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                    <tr>
                        <td style="text-align: right">
                            <asp:Label ID="Label4" runat="server" Text="Credit Card:"></asp:Label>
                        </td>
                        <td>
                            <asp:TextBox ID="tbCreditCard" runat="server" Width="221px"></asp:TextBox>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server"
                                ControlToValidate="tbCreditCard" ErrorMessage="Bad Card Number"
                                ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="2">
                            <asp:CompareValidator ID="PasswordCompare" runat="server"
                                ControlToCompare="Password" ControlToValidate="ConfirmPassword"
                                Display="Dynamic"
                                ErrorMessage="The Password and Confirmation Password must match."
                                ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                        </td>
                    </tr>
                    <tr><td colspan="2"></td></tr>
                    <tr>
                        <td align="center" colspan="2" style="color:Red;">
                            <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:CreateUserWizardStep>
        <asp:CompleteWizardStep runat="server" />
    </WizardSteps>
</asp:CreateUserWizard>
</asp:Content>


Copyright © 2013 ProTechs-Online.com; All rights reserved.