16,17 Asp PRG
16,17 Asp PRG
W17.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="w17.aspx.cs"
Inherits="w17" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<br />
<br />
<br />
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 />
</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)
{
}
}
<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;
}
protected void ValidateNameLength_Server(object source,
ServerValidateEventArgs args)
{
string name = args.Value;
if ( name.Length <30)
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}