0% found this document useful (0 votes)
13 views

16,17 Asp PRG

Uploaded by

krupa pipaliya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

16,17 Asp PRG

Uploaded by

krupa pipaliya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Registration using validation

 W17.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="w17.aspx.cs"
Inherits="w17" %>

<!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">

<asp:Label ID="Label1" runat="server" Text="Username"></asp:Label>


<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1" ErrorMessage="Must enter name"
ForeColor="Red"></asp:RequiredFieldValidator>

<br />

<asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>


<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />

<asp:Label ID="Label3" runat="server" Text="Confirm


Password"></asp:Label>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<asp:CompareValidator ID="CompareValidator1" runat="server"
ControlToCompare="TextBox2" ControlToValidate="TextBox3"
ErrorMessage="Password mustt be same"
ForeColor="Red"></asp:CompareValidator>
<br />

<asp:Label ID="Label4" runat="server" Text="Age"></asp:Label>


<asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
<asp:RangeValidator ID="RangeValidator1" runat="server"
ControlToValidate="TextBox4" ErrorMessage="Age must under 20"
ForeColor="Red"
MaximumValue="20" MinimumValue="0" ></asp:RangeValidator>

<br />

<asp:Label ID="Label5" runat="server" Text="City"></asp:Label>


<asp:DropDownList ID="ddlcity" runat="server">
<asp:ListItem Text="---SELECT City---" Value="0"></asp:ListItem>
<asp:ListItem Text="Junagadh" Value="1"></asp:ListItem>
<asp:ListItem Text="mumbai" Value="2"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="ddlcity" ErrorMessage="Enter city" ForeColor="Red"
InitialValue="0"></asp:RequiredFieldValidator>

<br />

<asp:Label ID="Label6" runat="server" Text="PinCode"></asp:Label>


<asp:TextBox ID="TextBox6" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1"
runat="server"
ControlToValidate="TextBox6" ErrorMessage="Must enter valid pincode"
ForeColor="Red"
ValidationExpression="\d{5}(-\d{4})?"></asp:RegularExpressionValidator>
<br />

<asp:Label ID="Label7" runat="server" Text="Mobile


number"></asp:Label>
<asp:TextBox ID="TextBox7" runat="server"></asp:TextBox></td>
<asp:RegularExpressionValidator
ID="regexPhoneNumber"
runat="server"
ControlToValidate="TextBox7"
ErrorMessage="Invalid phone number"

ValidationExpression="^(0|91)?[6-9][0-9]{9}$"></asp:RegularExpressionValidat
or>
<br />
<asp:Label ID="Label8" runat="server" Text="Email"></asp:Label>
<asp:TextBox ID="TextBox8" runat="server"></asp:TextBox>

<asp:RegularExpressionValidator ID="RegularExpressionValidator3"
runat="server"
ControlToValidate="TextBox8" ErrorMessage="Email must in proper
format"
ForeColor="Red"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\
w+)*"></asp:RegularExpressionValidator>
<br />

<asp:Button ID="Button1" runat="server" Text="Button" />

</form>
</body>
</html>

 W17.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class w17 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
}

Validation of name using customvalidation


 W16.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="w16.aspx.cs"
Inherits="w16" %>

<!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="lblName" runat="server" Text="Enter your
name:"></asp:Label>
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:CustomValidator ID="cvNameLength" runat="server"
ControlToValidate="txtName"
OnServerValidate="ValidateNameLength_Server"
ErrorMessage="Name must be less than 30 characters long."
Display="Dynamic"></asp:CustomValidator>
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
OnClick="btnSubmit_Click" />

</div>
</form>
</body>
</html>

 W16.spx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class w16 : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void ValidateNameLength_Server(object source,
ServerValidateEventArgs args)
{
string name = args.Value;
if ( name.Length <30)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}

protected void btnSubmit_Click(object sender, EventArgs e)


{
if (Page.IsValid)
{
// Handle the form submission
}
}
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy