2011-12-13 18 views
1

如何解決這個問題? 我有相同的問題有關這個鏈接沒有回答。 任何人都可以幫助我。比較驗證器日期類型c#.net

<telerik:RadDatePicker ID="DateTextBox" runat="server" Culture="en-GB" MinDate="1901-01-01" 
           TabIndex="4" FocusedDate="1991-01-01" MaxDate="2099-01-01"> 
           <Calendar UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" ViewSelectorText="x"> 
           </Calendar> 
           <DateInput DateFormat="dd/MM/yyyy" DisplayDateFormat="dd/MM/yyyy" TabIndex="4"> 
           </DateInput>                 
          </telerik:RadDatePicker> 

    <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="DateTextBox" ToolTip="The date to achieve the objective must be in the future" 
            ErrorMessage="The date to achieve the objective must be in the future" Operator="GreaterThan" Type="Date" 
            ValueToCompare='<%# DateTime.Now.ToString() %>'>*</asp:CompareValidator> 

Intermittent error with CompareValidator - ValueToCompare property is ""

+0

你必須張貼您的問題在開封后。你可以編輯你的帖子。 – adatapost

+0

thankx。這個怎麼做? – Geeth

+0

在鏈接問題中回答。主要想法是,你想比較字符串,但你設置數據類型「日期」。 – Samich

回答

4

你必須設置的CompareValidator以下屬性來驗證輸入的日期。

  1. 的ControlToValidate = 「控件ID」
  2. 的ErrorMessage = 「錯誤消息說明」
  3. 類型= 「日期」
  4. 算= 「DataTypeCheck」

編輯:的更新後實現OP。

可能是你必須設置yyyy-MM-dd格式。

ValueToCompare='<%# DateTime.Now.ToString("yyyy-MM-dd") %>'> 

看看線程在Telerik的論壇:

  1. ​​
  2. http://www.telerik.com/community/code-library/aspnet-ajax/calendar/validation-of-non-mandatory-datepicker-control.aspx
  3. http://demos.telerik.com/aspnet-ajax/calendar/examples/datepicker/validation/defaultcs.aspx