2011-12-19 31 views
0

我想比較2個文本框中的2個數據與DATE值,我使用CompareValidator比較它們,但它不適用於我,我該怎麼辦?這是我的CompareValidator代碼:DATE類型比較驗證程序

<asp:CompareValidator id="CompareValidator1" 
      runat="server" ErrorMessage="Invalid Date!" Type="Date" 
      ControlToValidate="SeconedDate_txt" 
      ControlToCompare="FirstDate_txt" Operator="GreaterThan"></asp:CompareValidator> 

回答

0

你輸入日期的格式和你的服務器有哪些區域設置?日期比較驗證是特定於語言環境的。

+0

我進入與壓延擴展Ajax工具包 –

0
<asp:CustomValidator ID="CustomValidator1" runat="server" 
    ErrorMessage="Invalid DateTime" 
    ControlToValidate="TextBox1" 
    OnServerValidate="CustomValidator1_ServerValidate"> 

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) 
    { 
      DateTime tempDateTime; 
      String textDateTime = TextBox1.Text; 
      if (DateTime.TryParse(textDateTime, out tempDateTime)) 
      { 
        args.IsValid = true; 
      } 
      else 
      { 
        args.IsValid = false; 
      } 
    } 
0

爲此,您需要AJAX控件工具包,請確保您下載的每一個.NET框架的正確版本。

<cc1:MaskedEditExtender ID="MaskedEditExtender5" runat="server" culturename="en-CA" mask="99/99/9999" masktype="Date" messagevalidatortip="true" argetcontrolid="txtEditExpireDate"></cc1:MaskedEditExtender> 
+0

數據,但可以maskeditextender比較2的值?我想在2文本框來比較2的值 –