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

RadTimePicker: client side assign time as string

2 Answers 124 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
archimede
Top achievements
Rank 1
archimede asked on 27 Mar 2015, 03:28 PM
Good day,

we are having some problems while trying to assign a string time value to a radtimepicker.

Page logic is as follows:
We have a formview with a bound control. That control is displaying a string with the value of a previous radtimepicker user inserted value.
We need to clientside assign the string value of the bound control to a radtimepicker in the current page.

We've read the api at
http://www.telerik.com/help/aspnet-ajax/calendar-client-side-basics.html
and there the only method seems to be set_selectedDate as a method to update the target field.
The problem is that set_selectedDate accepts only a date type, while our source type is a string.

We don't want to implement culture support for conversion from time string to time date, so we need to know:
1- is there an alternative client side method for setting the time in a radtimepicker, that uses a string parameter
2- is there an 'universal' datetime format that we can Date.Parse out time string ("08:30") so that the radtimepicker will accept it without culture and timezone problems?

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
archimede
Top achievements
Rank 1
answered on 27 Mar 2015, 03:37 PM
we received an error while posting, and thought the post was gone so we went ahead and reposted. please delete the other posts since they're duplicates thanks
0
Konstantin Dikov
Telerik team
answered on 01 Apr 2015, 01:31 PM
Hello Francesco,

If you can ensure that you have a correct time format, you can use the following approach for setting that time in the RadTimePicker:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function pageLoad() {
            var picker = $find("<%=RadTimePicker1.ClientID%>");
            picker.get_textBox().value = "8:00";
            picker.get_textBox().focus();
            picker.get_textBox().blur()
        }
    </script>
</telerik:RadCodeBlock>
 
<telerik:RadTimePicker runat="server" ID="RadTimePicker1"></telerik:RadTimePicker>

Please note that you need to focus and blur the textBox element in order for the control to update its selected date.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Calendar
Asked by
archimede
Top achievements
Rank 1
Answers by
archimede
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or