registration page

PHOTO EMBED

Wed Oct 29 2025 18:48:17 GMT+0000 (Coordinated Universal Time)

Saved by @final

๐Ÿงพ Program: Create ASP.NET Web Application for Name, Password, and Age Validation
๐Ÿชœ Step 1: Create New Web Application

Open Visual Studio โ†’ File โ†’ New โ†’ Project.

Select ASP.NET Web Application (.NET Framework).

Name it, e.g., UserValidation.

Choose Empty โ†’ Tick Web Forms โ†’ Click Create.

๐Ÿชœ Step 2: Add a Web Form

Right-click on the project โ†’ Add โ†’ Web Form.

Name it Register.aspx.

๐Ÿชœ Step 3: Switch to Design View

At the bottom of the editor, click Design tab.

You can now drag and drop controls visually from the Toolbox.

๐Ÿงฑ Step 4: Add Controls
๐Ÿ‘‰ (a) Name Field

Drag Label โ†’ Set Text = "Name", ID = Label1

Drag TextBox โ†’ ID = TextBox1

Drag RequiredFieldValidator โ†’ set properties:

ControlToValidate = TextBox1

ErrorMessage = Name is mandatory

๐Ÿ‘‰ (b) Password Field

Drag Label โ†’ Text = "Password", ID = Label2

Drag TextBox โ†’ ID = TextBox2, TextMode = Password

Drag RequiredFieldValidator โ†’ set:

ControlToValidate = TextBox2

ErrorMessage = Password missing

๐Ÿ‘‰ (c) Confirm Password Field

Drag Label โ†’ Text = "Confirm Password", ID = Label4

Drag TextBox โ†’ ID = TextBox4, TextMode = Password

Drag CompareValidator โ†’ set:

ControlToValidate = TextBox4

ControlToCompare = TextBox2

ErrorMessage = Passwords do not match

๐Ÿ‘‰ (d) Age Field

Drag Label โ†’ Text = "Age", ID = Label3

Drag TextBox โ†’ ID = TextBox3

Drag RangeValidator โ†’ set:

ControlToValidate = TextBox3

MinimumValue = 20, MaximumValue = 80

Type = Integer

ErrorMessage = Age must be between 20 and 80

๐Ÿชœ Step 5: Add Submit Button

Drag Button from Toolbox โ†’ ID = Button1

Set Text = Submit


๐Ÿงฑ (Email Field)

Drag Controls:

From the Toolbox โ†’ Standard, drag a Label control โ†’

Set Text = "Email"

Set ID = LabelEmail

Drag a TextBox โ†’

Set ID = TextBoxEmail

Add Validators:

RequiredFieldValidator

ControlToValidate = TextBoxEmail

ErrorMessage = "Email is required"

RegularExpressionValidator

ControlToValidate = TextBoxEmail

ErrorMessage = "Enter a valid Email Address"

ValidationExpression = ^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$



๐Ÿงฑ (User ID Field)

Drag Controls:

From Toolbox โ†’ Standard, drag a Label โ†’

Set Text = "User ID"

Set ID = LabelUserID

Drag a TextBox โ†’

Set ID = TextBoxUserID

Add Validators:

โœ… (a) RequiredFieldValidator

Ensures the User ID field is not left empty.

<asp:RequiredFieldValidator ID="rfvUserID" runat="server"
    ControlToValidate="TextBoxUserID"
    ErrorMessage="User ID is required"
    ForeColor="Red">
</asp:RequiredFieldValidator>

โœ… (b) RegularExpressionValidator

Ensures:

At least one uppercase letter

At least one digit

Length between 7 and 20 characters

Regex Expression:

^(?=.*[A-Z])(?=.*\d).{7,20}$







Normal webform
    webform1.aspx:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="registration.WebForm1" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title>Registration Form</title>
    <style type="text/css">
        .auto-style1 {
            width: 534px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <table style="width:100%;">
                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
                            ControlToValidate="TextBox1" ErrorMessage="Name is mandatory"></asp:RequiredFieldValidator>
                    </td>
                </tr>

                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
                            ControlToValidate="TextBox2" ErrorMessage="Password missing"></asp:RequiredFieldValidator>
                    </td>
                </tr>

                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label3" runat="server" Text="Age"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                        <asp:RangeValidator ID="RangeValidator1" runat="server"
                            ControlToValidate="TextBox3"
                            MinimumValue="20" MaximumValue="80"
                            Type="Integer" ErrorMessage="Age must be between 20 and 80"></asp:RangeValidator>
                    </td>
                </tr>

                <tr>
                    <td class="auto-style1">
                        <asp:Label ID="Label4" runat="server" Text="Confirm Password"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="TextBox4" runat="server" TextMode="Password"></asp:TextBox>
                        <asp:CompareValidator ID="CompareValidator2" runat="server"
                            ControlToValidate="TextBox4"
                            ControlToCompare="TextBox2"
                            ErrorMessage="Passwords do not match"></asp:CompareValidator>
                    </td>
                </tr>
            </table>
        </div>

        <p style="text-align:center;">
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
        </p>
    </form>
content_copyCOPY