本文介绍了日历控件中的范围验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我如何使用范围验证器选择当前日期和当前日期之前的下一个30个日期之间的任何日期,并且不应选择当前日期之前的日期。任何一个plz建议一些示例代码?

Hi,
How can i use a range validator to select any of the dates between the current date and next 30 dates after the current date and dates previous to current date should not be selected.can any one plz suggest some sample codes?

推荐答案

RangeValidator1.MinimumValue = DateTime.Now.Date.ToString("dd-MM-yy");
  RangeValidator1.MaximumValue = DateTime.Now.Date.AddDays(30).ToString("dd-MM-yy");


<tr>
     <td>
       <asp:TextBox ID="txtvalue" runat="server"></asp:TextBox>
       <asp:RangeValidator ID="Rvalid" runat="server"

ControlToValidate="txtvalue" ValidationGroup="Submit" ErrorMessage="your message"></asp:RangeValidator>
   </td>
</tr>
<tr>
   <td>
       <asp:Button ID="buttonclick"

ValidationGroup="Submit" runat="server" Text="Submit"

                         onclick="buttonclick_Click" />

   </td>
</tr>







在页面上加载CS页面






In CS page on page load

protected void Page_Load(object sender, EventArgs e)
         {
             Rvalid.MinimumValue = DateTime.Now.Date.ToString("MM-dd-yyyy");
             Rvalid.MaximumValue =
DateTime.Now.Date.AddDays(30).ToString("MM-dd-yyyy");
         }







希望这会对你有所帮助.... :) >


谢谢

Naveen




Hope this will help you.... :)

Thanks
Naveen


这篇关于日历控件中的范围验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 23:51