You are on page 1of 4

Experiment NO-9

Title: implement web application using asp.net with web control and provide input validation
Source code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="validation.aspx.vb"
Inherits="WebApplication9.validation" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}

.auto-style2 {
width: 144px;
}

.auto-style3 {
width: 144px;
text-align: right;
}

.auto-style4 {
width: 136px;
}

.auto-style5 {
width: 144px;
text-align: right;
height: 26px;
}

.auto-style6 {
width: 136px;
height: 26px;
}

.auto-style7 {
height: 26px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<table class="auto-style1">
<tr>
<td class="auto-style3">User Name</td>
<td class="auto-style4">
<asp:TextBox ID="txtname" runat="server"
Width="180px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="txtname" ErrorMessage="Plz Enter UserName"
ForeColor="Fuchsia"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Enter Email</td>
<td class="auto-style4">
<asp:TextBox ID="txtemail" runat="server"
Width="180px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ControlToValidate="txtemail" ErrorMessage="Enter EmailID"
ForeColor="Fuchsia"></asp:RequiredFieldValidator>
<br />
<asp:RegularExpressionValidator
ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtemail"
ErrorMessage="Plz Enter Correct EmailID" ForeColor="Fuchsia"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></
asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Enter Password</td>
<td class="auto-style4">
<asp:TextBox ID="txtpass" runat="server" Width="180px"
TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server" ControlToValidate="txtpass" ErrorMessage="Plz Enter Password"
ForeColor="Fuchsia"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style5">ReEnter Password</td>
<td class="auto-style6">
<asp:TextBox ID="txtrepass" runat="server" Width="180px"
TextMode="Password"></asp:TextBox>
</td>
<td class="auto-style7">
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server" ControlToValidate="txtrepass" ErrorMessage="ReEnter Password"
ForeColor="Fuchsia"></asp:RequiredFieldValidator>
<br />
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtpass" ControlToValidate="txtrepass" ErrorMessage="Password
must me same" ForeColor="Fuchsia"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Enter Full Name</td>
<td class="auto-style4">
<asp:TextBox ID="txtFn" runat="server"
Width="180px"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server" ControlToValidate="txtFn" ErrorMessage="Plz Enter Full Name"
ForeColor="Fuchsia"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style3">Select Your Country</td>
<td class="auto-style4">
<asp:DropDownList ID="ddlCity" runat="server"
Width="187px">
<asp:ListItem Value="0" Selected="True">--Select--
</asp:ListItem>
<asp:ListItem Value="1">India</asp:ListItem>
<asp:ListItem Value="2">Australia</asp:ListItem>
<asp:ListItem Value="3">America</asp:ListItem>
<asp:ListItem Value="4">South Africa</asp:ListItem>
<asp:ListItem Value="5">England</asp:ListItem>
<asp:ListItem Value="6">Kenya</asp:ListItem>
<asp:ListItem Value="7">WestIndies</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
runat="server" InitialValue="0" ControlToValidate="ddlCity" ErrorMessage="Plz
Select Your Country" ForeColor="Fuchsia"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td class="auto-style4"> </td>
<td> </td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td class="auto-style4">
<asp:Button ID="Button1" runat="server" Text="Submit"
ForeColor="#FF66FF" OnClick="Button1_Click" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Label"
Visible="false"></asp:Label>
</td>
</tr>
</table>
<div>
</div>
</form>
<p>

</p>
</body>
</html>

Output:

You might also like