RadDatePicker can't set date under 01/01/1820

6 posts, 1 answers
  1. Desarrollo
    Desarrollo avatar
    2 posts
    Member since:
    Dec 2011

    Posted 09 Apr 2013 Link to this post

    Hi, 

    I need some help with a radDatePicker, I can´t set min date to 01/01/1800. I've tried with these properties but nothing I get the error :"No se puede crear un objeto de tipo 'System.DateTime' a partir de su representación de cadena '01/01/1800 12:00:00 a.m.' para la propiedad 'MinDate'."

    <telerik:RadDatePicker ID="dtpDesde" runat="server" SkipMinMaxDateValidationOnServer="True" MinDate="01/01/1800 12:00:00 a.m." Calendar-FocusedDate="01/01/1800 12:00:00 a.m." Calendar-RangeMinDate="01/01/1800 12:00:00 a.m." Calendar-RangeSelectionStartDate="01/01/1800 12:00:00 a.m." DateInput-MinDate="01/01/1800 12:00:00 a.m." FocusedDate="01/01/1800 12:00:00 a.m.">


    If I only try with the property  "SkipMinMaxDateValidationOnServer="True"" , the control validation in the browser show me an error and  the control clear the date.

    Could you please advise me  right way to allow dates under the default min value.

    Thanks..

    In RadDatePicker

    If  not able to select the date less than the 1980, 

  2. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 10 Apr 2013 Link to this post

    Hi Desarrollo,

    The that that you use should be valid string representation to be parsed using DateTime.Parse:
    http://msdn.microsoft.com/en-us/library/1k1skd40.aspx
    This markup will work for you:
    <telerik:RadDatePicker ID="dtpDesde"
        runat="server"
        SkipMinMaxDateValidationOnServer="false"
        MinDate="01/01/1800 00:00:00"
        Calendar-RangeMinDate="01/01/1800 00:00:00"
        Calendar-RangeSelectionStartDate="01/01/1800 00:00:00"
        Calendar-FocusedDate="01/01/1800 00:00:00"
        DateInput-MinDate="01/01/1800 00:00:00"
        FocusedDate="01/01/1800 00:00:00">
    </telerik:RadDatePicker>

    Greetings,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Desarrollo
    Desarrollo avatar
    2 posts
    Member since:
    Dec 2011

    Posted 10 Apr 2013 Link to this post

    Excellent Vasil, it works perfect, Thank you...
    Greetings
  5. Imran
    Imran avatar
    2 posts
    Member since:
    Apr 2016

    Posted 28 Apr Link to this post

    I want to set 00/00/00  to radDatepicker how can i do this?

     

  6. Imran
    Imran avatar
    2 posts
    Member since:
    Apr 2016

    Posted 28 Apr in reply to Vasil Link to this post

    I want to set 00/00/00  to radDatepicker how can i do this?
  7. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 28 Apr Link to this post

    Hi Imran,

    The 0/0/0 is not valid year. The years stars from 1, and the months are also from 1 to 12, same as days.
    The minimum you can set is 1/1/1, but in case you place it in the markup it will use the ShortYearCenturyEnd is by default 2029 you will end up with 2001/1/1

    So you need to set it in the code-behind, here is an example:
    <telerik:RadDatePicker runat="server" ID="RadDatePicker1">
    </telerik:RadDatePicker>

    protected void Page_Load(object sender, EventArgs e)
    {
        RadDatePicker1.MinDate = new DateTime(1,1,1);
        RadDatePicker1.SelectedDate = new DateTime(1,1,1);
    }

    Regards,
    Vasil
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017