<%@ Page clienttarget=downlevel %>
<html>
<head>
<title>RangeValidator Sample</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
void ValidateBtnClick ( object src, EventArgs e ) {
rangeVal.Type = ( ValidationDataType ) listTypes.SelectedIndex;
rangeVal.MinimumValue = txtMin.Text;
rangeVal.MaximumValue = txtMax.Text;
rangeVal.Validate ( );
if ( Page.IsValid ) {
lblmsg.Text = "Value is within valid range!";
}
else {
lblmsg.Text = "Value is not within valid range!";
}
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>RangeValidator Sample</h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<table bgcolor="#eeeeee" cellpadding=10>
<tr valign="top">
<td><h5>Value to Check:</h5>
<asp:textbox selected id="txtComp" runat="server" />
<br>
<asp:requiredfieldvalidator runat="server"
controltovalidate="txtComp"
errormessage="Field cannot be blank" /></td>
<td>
<h5>Data Type:</h5>
<asp:dropdownlist id="listTypes" runat="server">
<asp:listitem selected value="String">String</asp:listitem>
<asp:listitem value="Integer">Integer</asp:listitem>
<asp:listitem value="Double">Double</asp:listitem>
<asp:listitem value="Date">Date</asp:listitem>
<asp:listitem value="Currency">Currency</asp:listitem>
</asp:dropdownlist></td>
<td>
<h5>Minimum Value:</h5>
<asp:textbox id="txtMin" runat="server" />
<br>
<asp:requiredfieldvalidator runat="server"
controltovalidate="txtMin"
errormessage="Field cannot be blank" /></td>
<td>
<h5>Maximum Value:</h5>
<asp:textbox id="txtMax" runat="server" />
<br>
<asp:requiredfieldvalidator runat="server"
controltovalidate="txtMax"
errormessage="Field cannot be blank" /></td></tr>
</table>
<br>
<asp:button text="Validate" onClick="ValidateBtnClick" runat="server" />
<br>
<asp:rangevalidator id="rangeVal" runat="server"
controltovalidate="txtComp" />
<br>
<asp:label id="lblmsg" runat="server" />
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>