RadTimePicker and RequiredFieldValidator

4 posts, 1 answers
  1. Alexander Shashkin
    Alexander Shashkin avatar
    15 posts
    Member since:
    May 2010

    Posted 10 Sep 2011 Link to this post

    Hi all,
    I have one problem with RadTimePicker. Here my code:
    <telerik:RadTimePicker ID="RadTimePicker1" runat="server" MinDate="2011-09-11 10:00:01">
    </telerik:RadTimePicker>
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadTimePicker1"
        ErrorMessage="AAA!"></asp:RequiredFieldValidator>
    <asp:Button runat="server" ID="btnSubmit" OnClick="btnSubmit_Click" Text="Submit" />

    If I will click on submit button then I will see "AAA!" - it is ok.
    If I will choose 11:00 and then on 9:00 then I will have 11:00 in time picker with warning icon. but if I will click on submit then I will get real submit and null in RadTimePicker1.SelectedDate, of course Page.IsValid will be false, but I will get post back.
    I think this behavior is wrong. May be page should be valid and time picker should have 11:00 because user see that he has 11:00 in time picker and warning only means that he can't choose 9:00? 

    Can anybody suggest a workaround?
    P.S. I don't want change RequiredFieldValidator to CustomValidator.
  2. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 15 Sep 2011 Link to this post

    Hi Alexander,

     You can use the client-side events of the TimePicker and its TimeView component to modify the behavior according to your needs. For example you can handle the OnClientTimeSelecting event of the TimeView of the RadTimePicker and cancel the selection of the time from the popup if it is not valid, then if you wish you can close the popup and apply warning styles to the textbox using the client-side API of the control.

    Kind regards,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
  3. Alexander Shashkin
    Alexander Shashkin avatar
    15 posts
    Member since:
    May 2010

    Posted 15 Sep 2011 Link to this post

    Hi Marin,
    Thank you for your answer! Yes, I understand that I can write my own logic in Client-Side events, use CustomValidator and so on. I already wrote fix for this issue in my project, but I think that this is bug and it should be fixed in next releases of Telerik. Why I think that this is bug? Because user see "11:00" in time picker and I think it is logical to suggest that field will have "11:00" on submit. 
  4. Answer
    Marin
    Admin
    Marin avatar
    1057 posts

    Posted 17 Sep 2011 Link to this post

    Hi Alexander,

     Thank you for the feedback.

    I have forwarded this issue to our development team for further investigation and to decide how to proceed in this case.

    Additionally you can also access the "11:00" value in the textbox in the following way:

    RadTimePicker1.DateInput.InvalidTextBoxValue

    Regards,
    Marin
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Back to Top