RadTimePicker Issue

2 posts, 1 answers
  1. Prasanth100
    Prasanth100 avatar
    17 posts
    Member since:
    Oct 2012

    Posted 20 Dec 2013 Link to this post

    Hello Gurus,

         i am using RadTimePicker in my project, i have appointment date and appointment time.
    Scenario : if i select date as today, then RadTimePicker time should be more than current time.
         For eg : if the current time is 10'O clock, the RadTimePicker time should be start with 11:00  
    (Attached a screenshot)
     
     
    <telerik:RadDatePicker runat="server" ID="RadDateAppointment" Width="200px" Skin="Metro" >
                <Calendar ID="Calendar5" runat="server" Skin="Metro" EnableKeyboardNavigation="true">
                </Calendar>
                <DateInput ID="D" runat="server" DisplayDateFormat="dd MMM yyyy" DateFormat="dd MMM yyyy"
                    EmptyMessage="dd/mm/yyyy" >
                </DateInput>
            </telerik:RadDatePicker>
     
    <telerik:RadTimePicker ID="RadTimePickerAppointment" Width="110px" Skin="Metro" runat="server">
                <DateInput ID="DateInput1" runat="server">
                </DateInput>
                <TimeView ID="TimeView1" runat="server" CellSpacing="-1">   
                </TimeView>  
         </telerik:RadTimePicker>

    Thanks in Advance.

        Prasanth

         
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Dec 2013 Link to this post

    Hi Prasanth,

    Please have a look into the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadDatePicker runat="server" AutoPostBack="true" ID="RadDateAppointment"
        Width="200px" OnSelectedDateChanged="RadDateAppointment_SelectedDateChanged">
        <DateInput ID="D" runat="server" DisplayDateFormat="dd MMM yyyy" DateFormat="dd MMM yyyy"
            EmptyMessage="dd/mm/yyyy">
        </DateInput>
    </telerik:RadDatePicker>
    <telerik:RadTimePicker ID="RadTimePickerAppointment" Width="110px" runat="server">
        <DateInput runat="server">
        </DateInput>
        <TimeView runat="server" CellSpacing="-1">
        </TimeView>
    </telerik:RadTimePicker>

    C#:
    protected void RadDateAppointment_SelectedDateChanged(object sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
    {
        DateTime date = DateTime.Today;
        if (e.NewDate == date)
        {
            string time = DateTime.Now.ToString("HH");
            int hour = Convert.ToInt32(s);
            RadTimePickerAppointment.TimeView.StartTime = new TimeSpan(hour, 0, 0);
        }
    }

    Hope this will helps you.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top