T.Y.I.T. SEM V P-III Advanced Web Programming Roll No.
– IT-2221
PRACTICAL NO 4: Working with Form Controls
Q.1. Create a registration form to demonstrate use of various Validation controls.
GUI:
Source Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="validation.aspx.cs"
Inherits="validation" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Name:"></asp:Label>
<asp:TextBox ID="txtname" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
T.Y.I.T. SEM V P-III Advanced Web Programming Roll No. – IT-2221
ControlToValidate="txtname" ErrorMessage="Field can't be
empty!!"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text="Age:"></asp:Label>
<asp:TextBox ID="txtage" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="txtage" ErrorMessage="The value is not in the range!!"
MaximumValue="60" MinimumValue="18"></asp:RangeValidator>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Email ID:"></asp:Label>
<asp:TextBox ID="txtemail" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ControlToValidate="txtemail" ErrorMessage="Email id is not valid!!"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></
asp:RegularExpressionValidator>
<br />
<br />
<asp:Label ID="Label4" runat="server" Text="Password:"></asp:Label>
<asp:TextBox ID="txtpass" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="txtrpass" ControlToValidate="txtpass"
ErrorMessage="Password don't match"></asp:CompareValidator>
<br />
<br />
<asp:Label ID="Label5" runat="server" Text="Retype:"></asp:Label>
<asp:TextBox ID="txtrpass" runat="server"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label6" runat="server" Text="Gender:"></asp:Label>
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="gender"
Text="Male" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="gender"
Text="Female" />
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Submit" />
<asp:Button ID="Button2" runat="server" Text="Reset" />
<br />
<br />
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
HeaderText="PLEASE CORRECT THE FOLLOWING ERRORS" />
<br />
T.Y.I.T. SEM V P-III Advanced Web Programming Roll No. – IT-2221
</div>
</form>
</body>
</html>
Q.2.Create Web Form to demonstrate use of Adrotator Control.
GUI:
Source Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="adrotatar.aspx.cs"
Inherits="adrotatar" %>
T.Y.I.T. SEM V P-III Advanced Web Programming Roll No. – IT-2221
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:AdRotator ID="AdRotator1" runat="server" DataSourceID="XmlDataSource1" />
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/XMLFile.xml">
</asp:XmlDataSource>
</div>
</form>
</body>
</html>
Code:
XMLFILE.xml
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
<Ad>
<ImageUrl>Images\p1.jpg</ImageUrl>
<NavigateUrl>https://www.plants.com/</NavigateUrl>
<AlternateText>Order Plants</AlternateText>
<Impressions>20</Impressions>
<Keyword>plants</Keyword>
<Height>500</Height>
<width>2000</width>
</Ad>
<Ad>
<ImageUrl>Images\p2.jpg</ImageUrl>
<NavigateUrl>https://www.plants.com/</NavigateUrl>
<AlternateText>Order Plants</AlternateText>
<Impressions>20</Impressions>
<Keyword>plants</Keyword>
<Height>500</Height>
<width>2000</width>
</Ad>
<Ad>
<ImageUrl>Images\p3.jpg</ImageUrl>
<NavigateUrl>https://www.plants.com/</NavigateUrl>
<AlternateText>Order Plants</AlternateText>
<Impressions>10</Impressions>
<Keyword>plants</Keyword>
<Height>500</Height>
<width>2000</width>
T.Y.I.T. SEM V P-III Advanced Web Programming Roll No. – IT-2221
</Ad>
<Ad>
<ImageUrl>Images\p4.jpg</ImageUrl>
<NavigateUrl>https://www.plants.com/</NavigateUrl>
<AlternateText>Order Plants</AlternateText>
<Impressions>30</Impressions>
<Keyword>plants</Keyword>
<Height>500</Height>
<width>2000</width>
</Ad>
</Advertisements>
Output:
T.Y.I.T. SEM V P-III Advanced Web Programming Roll No. – IT-2221