RadDatePicker - compare validater

2 posts, 0 answers
  1. lewismoten
    lewismoten avatar
    18 posts
    Member since:
    Nov 2006

    Posted 30 May 2008 Link to this post

    I need to be able to prevent a user from posting a form if they have entered an invalid date (5/121/2008) with the rad date picker. I added a CompareValidator and the form still posts, but with an empty value. When the form reloads, the date picker is empty.

    I've simplified the code and found the problem still exists.

    • Enter a bad date
    • click the button
      • Compare validator didn't complain about an invalid date
      • Date picker is now empty
      • Label has a large number indicating the information was posted
        • represents the ticks of last time posted
    1 <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %> 
    2  
    3 <%@ Register Assembly="RadCalendar.Net2, Version=2.2.2.0, Culture=neutral, PublicKeyToken=a1432cd341173140" 
    4     Namespace="Telerik.WebControls" TagPrefix="rad" %> 
    5  
    6 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    7  
    8 <html xmlns="http://www.w3.org/1999/xhtml" > 
    9 <head runat="server">  
    10     <title>Untitled Page</title> 
    11       
    12 </head> 
    13 <body> 
    14     <form id="form1" runat="server">  
    15     <div> 
    16         Last Submitted:  
    17         <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br /> 
    18         <br /> 
    19         <rad:RadDatePicker DateFormat="MM/dd/yyyy" id="RadDatePicker1" runat="server" Culture="English (United States)">  
    20                 <dateinput skin=""></dateinput> 
    21                 </rad:RadDatePicker> 
    22         <br /> 
    23         <br /> 
    24         <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="RadDatePicker1" 
    25             ErrorMessage="CompareValidator" Operator="DataTypeCheck" Type="Date"></asp:CompareValidator><br /> 
    26         <br /> 
    27         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>  
    28     </form> 
    29 </body> 
    30 </html> 
    31  

    and the code behind ....

    1 using System;  
    2 using System.Data;  
    3 using System.Configuration;  
    4 using System.Web;  
    5 using System.Web.Security;  
    6 using System.Web.UI;  
    7 using System.Web.UI.WebControls;  
    8 using System.Web.UI.WebControls.WebParts;  
    9 using System.Web.UI.HtmlControls;  
    10  
    11 public partial class _Default : System.Web.UI.Page   
    12 {  
    13     protected void Button1_Click(object sender, EventArgs e)  
    14     {  
    15         Label1.Text = DateTime.Now.Ticks.ToString();  
    16     }  
    17 }  
    18  
  2. lewismoten
    lewismoten avatar
    18 posts
    Member since:
    Nov 2006

    Posted 30 May 2008 Link to this post

    After some more hunting, I found an answer @ http://www.telerik.com/community/forums/thread/b311D-bbagac.aspx
Back to Top