Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在ASP.Net中使用验证器动态验证年份?_C#_Asp.net - Fatal编程技术网

C# 如何在ASP.Net中使用验证器动态验证年份?

C# 如何在ASP.Net中使用验证器动态验证年份?,c#,asp.net,C#,Asp.net,我必须验证输入的年份必须小于或等于当前年份。我在ASP.Net和C#中使用服务器端验证程序,所有验证程序都在验证程序组中。因此,请建议我在同一时间内验证另一个条件 谢谢 Amit Ranjan.使用ASP.NET CompareValidator 例如,如果您有一个id为TextBox1的文本框,它接受“yyy”格式的年份,那么您可以执行以下操作: Year: <asp:TextBox id="TextBox1" runat="server"></asp:TextBox>

我必须验证输入的年份必须小于或等于当前年份。我在ASP.Net和C#中使用服务器端验证程序,所有验证程序都在验证程序组中。因此,请建议我在同一时间内验证另一个条件

谢谢
Amit Ranjan.

使用ASP.NET CompareValidator

例如,如果您有一个id为TextBox1的文本框,它接受“yyy”格式的年份,那么您可以执行以下操作:

Year: 
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
  &nbsp;
<asp:CompareValidator id="CompareValidator1" runat="server" 
  Operator="LessThan" ControlToValidate="TextBox1" ErrorMessage="Year must 
  be less than current year" Type="Integer"></asp:CompareValidator>
还要记住,使用验证器不会阻止提交;将它们与ValidationSummary控件结合使用


有关MSDN的详细信息:

使用ASP.NET CompareValidator

例如,如果您有一个id为TextBox1的文本框,它接受“yyy”格式的年份,那么您可以执行以下操作:

Year: 
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
  &nbsp;
<asp:CompareValidator id="CompareValidator1" runat="server" 
  Operator="LessThan" ControlToValidate="TextBox1" ErrorMessage="Year must 
  be less than current year" Type="Integer"></asp:CompareValidator>
还要记住,使用验证器不会阻止提交;将它们与ValidationSummary控件结合使用

更多有关MSDN的信息: