Practical 4 (A, B, C) Awp
Practical 4 (A, B, C) Awp
4 A
CODE:
1] Default.aspx
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 343px;
}
.auto-style3 {
width: 343px;
height: 23px;
}
.auto-style4 {
height: 23px;
}
.auto-style5 {
width: 226px;
}
.auto-style6 {
height: 23px;
width: 226px;
}
.auto-style7 {
width: 343px;
height: 27px;
}
.auto-style8 {
width: 226px;
height: 27px;
}
.auto-style9 {
height: 27px;
}
</style>
</head>
<body>
<form id="form2" runat="server">
<div>
<table class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Label ID="Label1" runat="server" Text="Enter Name :
"></asp:Label>
</td>
<td class="auto-style5">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1" ErrorMessage="* Name Required"
ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label2" runat="server" Text="Enter
Password :"></asp:Label>
</td>
<td class="auto-style5">
<asp:TextBox ID="TextBox2" runat="server"
TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2"
runat="server" ControlToValidate="TextBox2" ErrorMessage="*Password
Required" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label3" runat="server" Text="Confirm
Password :"></asp:Label>
</td>
<td class="auto-style5">
<asp:TextBox ID="TextBox3" runat="server"
TextMode="Password"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator3"
runat="server" ControlToValidate="TextBox3" ErrorMessage="*Password
Required" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox2" ControlToValidate="TextBox3"
ErrorMessage="*Enter same password"
ForeColor="Red"></asp:CompareValidator>
</td>
</tr>
<tr>
<td class="auto-style2">
<asp:Label ID="Label4" runat="server" Text="Enter Your Age :
"></asp:Label>
</td>
<td class="auto-style5">
<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator4"
runat="server" ControlToValidate="TextBox4" ErrorMessage="*Enter age"
ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox4" ErrorMessage="*Age required should be between
18 to 40" ForeColor="Red" MaximumValue="40" MinimumValue="18"
Type="Integer"></asp:RangeValidator>
</td>
</tr>
<tr>
<td class="auto-style7">
<asp:Label ID="Label5" runat="server" Text="Enter your Email-
ID :"></asp:Label>
</td>
<td class="auto-style8">
<asp:TextBox ID="TextBox5" runat="server"
TextMode="Email"></asp:TextBox>
</td>
<td class="auto-style9">
<asp:RequiredFieldValidator ID="RequiredFieldValidator5"
runat="server" ControlToValidate="TextBox5" ErrorMessage="*Email ID
required" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server" ControlToValidate="TextBox5" ErrorMessage="*Email ID should
be proper" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\
w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="auto-style3">
<asp:Label ID="Label6" runat="server" Text="User
ID :"></asp:Label>
</td>
<td class="auto-style6">
<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
</td>
<td class="auto-style4">
<asp:RequiredFieldValidator ID="RequiredFieldValidator6"
runat="server" ControlToValidate="TextBox6" ErrorMessage="*User ID
required" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="CustomValidator1" runat="server"
ControlToValidate="TextBox6" ErrorMessage="*User ID should write properly"
ForeColor="Red"
OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
</td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td class="auto-style5">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
style="height: 26px" Text="Button" />
</td>
<td> </td>
</tr>
<tr>
<td class="auto-style2"> </td>
<td class="auto-style5">
<asp:Label ID="Label7" runat="server"></asp:Label>
</td>
<td> </td>
</tr>
</table>
</div>
</form>
</body>
</html>
2] Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
}
protected void CustomValidator1_ServerValidate(object source,
ServerValidateEventArgs args)
{
string str = args.Value;
if (str.Length > 3)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
}
3] web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please
visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode"
value="None"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
OUTPUT :
PRACTICAL NO. 4B
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
2] XMLFile1.xml
</Advertisements>
OUTPUT:
PRACTICAL 4 C
Code:
1] WebForm1.aspx
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Text="Button" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<uc1:WebUserControl ID="WebUserControl1" runat="server" />
</div>
</form>
</body>
</html>
2] WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace usercontrol
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
4] WebUserControl1.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace usercontrol
{
public partial class WebUserControl1 : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{