compare_validator.aspx.cs
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="compare_validator.aspx.cs" Inherits="our_program.compare_validator" %>
<!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>
<center><h1>compare validator</h1></center>
<script runat="server">
void Button_Click(Object sender, EventArgs e)
{
if (Page.IsValid)
{
lblOutput.Text = "Result: Valid!";
}
else
{
lblOutput.Text = "Result: Not valid!";
}
}
void check_operator(Object sender, EventArgs e)
{
Compare1.Operator = (ValidationCompareOperator)listbox1.SelectedIndex;
Compare1.Validate();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<center>
<div style="height: 167px">
<asp:TextBox ID="txt1" runat="server" ></asp:TextBox>
<br />
<asp:TextBox ID="txt2" runat="server" ></asp:TextBox>
<br/>
<asp:ListBox ID="listbox1" runat="server" OnSelectedIndexChanged="check_operator" Height="131px" Width="125px" >
<asp:ListItem Selected="True" Value="Equal">Equal</asp:ListItem>
<asp:ListItem Value="NotEqual">NotEqual</asp:ListItem>
<asp:ListItem Value="GreaterThan">GreaterThan</asp:ListItem>
<asp:ListItem Value="GreaterThanEqual">GreaterThanEqual</asp:ListItem>
<asp:ListItem Value="LessThan">LessThan</asp:ListItem>
<asp:ListItem Value="LessThanEqual">LessThanEqual</asp:ListItem>
</asp:ListBox>
<br />
<asp:Button id="Button1" Text="Validate" OnClick="Button_Click" runat="server"/>
<asp:Label id="lblOutput" Font-Names="verdana" Font-Size="10pt" runat="server"/>
<asp:CompareValidator id="Compare1" ControlToValidate="txt1" ControlToCompare="txt2" EnableClientScript="False" Type="Integer" runat="server"/>
</div>
</center>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="compare_validator.aspx.cs" Inherits="our_program.compare_validator" %>
<!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>
<center><h1>compare validator</h1></center>
<script runat="server">
void Button_Click(Object sender, EventArgs e)
{
if (Page.IsValid)
{
lblOutput.Text = "Result: Valid!";
}
else
{
lblOutput.Text = "Result: Not valid!";
}
}
void check_operator(Object sender, EventArgs e)
{
Compare1.Operator = (ValidationCompareOperator)listbox1.SelectedIndex;
Compare1.Validate();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<center>
<div style="height: 167px">
<asp:TextBox ID="txt1" runat="server" ></asp:TextBox>
<br />
<asp:TextBox ID="txt2" runat="server" ></asp:TextBox>
<br/>
<asp:ListBox ID="listbox1" runat="server" OnSelectedIndexChanged="check_operator" Height="131px" Width="125px" >
<asp:ListItem Selected="True" Value="Equal">Equal</asp:ListItem>
<asp:ListItem Value="NotEqual">NotEqual</asp:ListItem>
<asp:ListItem Value="GreaterThan">GreaterThan</asp:ListItem>
<asp:ListItem Value="GreaterThanEqual">GreaterThanEqual</asp:ListItem>
<asp:ListItem Value="LessThan">LessThan</asp:ListItem>
<asp:ListItem Value="LessThanEqual">LessThanEqual</asp:ListItem>
</asp:ListBox>
<br />
<asp:Button id="Button1" Text="Validate" OnClick="Button_Click" runat="server"/>
<asp:Label id="lblOutput" Font-Names="verdana" Font-Size="10pt" runat="server"/>
<asp:CompareValidator id="Compare1" ControlToValidate="txt1" ControlToCompare="txt2" EnableClientScript="False" Type="Integer" runat="server"/>
</div>
</center>
</form>
</body>
</html>
compare_validator.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace our_program
{
public partial class compare_validator : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
}
No comments:
Post a Comment