This is a migrated thread and some comments may be shown as answers.

RadTimePicker and RequiredFieldValidator

3 Answers 78 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Alexander Shashkin
Top achievements
Rank 1
Alexander Shashkin asked on 10 Sep 2011, 09:49 PM
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.

3 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 15 Sep 2011, 09:38 AM
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
0
Alexander Shashkin
Top achievements
Rank 1
answered on 15 Sep 2011, 10:06 AM
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. 
0
Accepted
Marin
Telerik team
answered on 17 Sep 2011, 09:41 AM
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
Tags
Calendar
Asked by
Alexander Shashkin
Top achievements
Rank 1
Answers by
Marin
Telerik team
Alexander Shashkin
Top achievements
Rank 1
Share this question
or