RadTimePicker: client side assign time as string

3 posts, 0 answers
  1. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 27 Mar 2015 Link to this post

    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. archimede
    archimede avatar
    103 posts
    Member since:
    Jul 2006

    Posted 27 Mar 2015 in reply to archimede Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 01 Apr 2015 Link to this post

    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.

     
Back to Top