RadDateTimePicker demo

7 posts, 1 answers
  1. miksh
    miksh avatar
    275 posts
    Member since:
    Nov 2006

    Posted 24 Apr 2014 Link to this post

    I suggest you to review your online demo in "Time picker/DateTime picker" section and add more demo/info re. RadDateTimePicker. Specifically, I would suggest:
    • Add "DateTimePicker - First Look"
    • MOST IMPORTANT: Add DateTimePicker range validation as it's different from TimePicker!            
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 29 Apr 2014 Link to this post

    Hello Michael,

    Thank you for your feedback and for your suggestions.

    I will forward your suggestion for online demos regarding the RadDateTimePicker control, but in general, the control is combination between RadDatePicker and RadTimePicker, and detailed information for both controls is available at out online demos and help articles.

    Furthermore, the same demo for RadTimePicker validation could be used with RadDateTimePicker control by just changing the control:
    <telerik:RadScriptBlock runat="server" ID="RadCodeBlock1">
        <script type="text/javascript">
            //<![CDATA[
            var RadTimePicker1;
            var RadTimePicker2;
     
            function validate(sender, args) {
                var Date1 = new Date(RadTimePicker1.get_selectedDate());
                var Date2 = new Date(RadTimePicker2.get_selectedDate());
                args.IsValid = true;
                if ((Date2 - Date1) < 0) {
                    alert("The second time value should be greater than the first!");
                    args.IsValid = false;
                }
            }
     
            function onLoadRadTimePicker1(sender, args) {
                RadTimePicker1 = sender;
            }
     
            function onLoadRadTimePicker2(sender, args) {
                RadTimePicker2 = sender;
            }
            //]]>
        </script>
    </telerik:RadScriptBlock>
     
    <telerik:RadDateTimePicker ID="RadTimePicker1" runat="server">
        <DateInput ID="DateInput1" runat="server">
            <ClientEvents OnLoad="onLoadRadTimePicker1"></ClientEvents>
        </DateInput>
    </telerik:RadDateTimePicker>
    <asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="RadTimePicker1"
        ErrorMessage="Enter a date!"></asp:RequiredFieldValidator>
     
    <telerik:RadDateTimePicker ID="RadTimePicker2" runat="server">
        <DateInput ID="DateInput2" runat="server">
            <ClientEvents OnLoad="onLoadRadTimePicker2"></ClientEvents>
        </DateInput>
    </telerik:RadDateTimePicker>
    <asp:RequiredFieldValidator runat="server" ID="Requiredfieldvalidator2" ControlToValidate="RadTimePicker2"
        ErrorMessage="Enter a date!"></asp:RequiredFieldValidator>
     
    <asp:CustomValidator ID="CustomValidator1" EnableClientScript="true" runat="server"
        ControlToValidate="RadTimePicker2" ClientValidationFunction="validate">
    </asp:CustomValidator>
    <asp:Button runat="server" Text="Save" ID="Button1"></asp:Button>

    Please feel free to get back to us If you need any further assistance with the validation.


    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. miksh
    miksh avatar
    275 posts
    Member since:
    Nov 2006

    Posted 29 Apr 2014 in reply to Konstantin Dikov Link to this post

    Thanks Konstantin, I'll try this approach - I believe it would work.

    Could you comment the note made in http://www.telerik.com/help/aspnet-ajax/calendar-validation.html

    You need to set the Type property of the CompareValidator to "Date" in order to work with a RadDatePicker. When working with RadTimePicker, or RadDateTimePicker control, the property must be set to "String".

    Would it be simpler solution or your documentation is incorrect?
  5. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 02 May 2014 Link to this post

    Hello Miksh,

    The help article that you are referring to demonstrates how to use CompareValidator for comparing two dates. On the other hand, the online demo is using CustomValidator, and since the validation is handled manually, the same approach could be used with both - RadDatePicker and RadDateTimePicker.

    As for which approach should be demonstrated in the help article, since comparing values from pickers with CompareValidator has its specifics and the CustomValidator could implement any custom logic, in my opinion the CompareValidator approach is more suitable for help article.


    Best Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. miksh
    miksh avatar
    275 posts
    Member since:
    Nov 2006

    Posted 02 May 2014 in reply to Konstantin Dikov Link to this post

    Ok thank you. So in general case I would prefer to use CompareValidator as the simplest solution. 
    The only concern, since it uses a string value to compare would it work for any culture?
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 May 2014 in reply to miksh Link to this post

    Hi miksh,

    The CompareValidator will work with Culture property of RadDatePicker. Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadDatePicker ID="StartDate" MinDate="2008/1/1" runat="server" Culture="fr-FR">
    </telerik:RadDatePicker>
    <telerik:RadDatePicker ID="EndDate" MinDate="2008/1/1" runat="server" Culture="en-US">
    </telerik:RadDatePicker>
    <asp:CompareValidator ID="dateCompareValidator" runat="server" ControlToValidate="EndDate"
        ControlToCompare="StartDate" Operator="GreaterThan" Type="Date" ErrorMessage="The end date must be after the start one.">
    </asp:CompareValidator>
    <asp:Button runat="server" Text="Submit" ID="Button1" />

    Thanks,
    Princy.
  8. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 07 May 2014 Link to this post

    Hello Miksh,

    As Princy pointed out (and as documented in our help article RadCalendar - Web Pages Validation), when you use RadDatePicker you could use the CompareValidator by setting the Type to "Date", and when RadDateTimePicker is used, the Type should be set to "String".

    In general, the validation for RadDateTimePicker should work correctly, regardless the used culture.


    Best Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017