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

Highlight Date in Popup But Do Not Display in Textbox By Default

3 Answers 129 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 03 Feb 2015, 05:48 PM
Support,

I have 2 datepicker controls.  Both controls have no date selected by default.  After datepicker #1 has a date selected, the requirement is that datepicker #2's textbox is still blank, but when the user clicks on the calendar icon, the calendar popup has the same date highlighted as the selected date of datepicker #1.

I've tried setting the .SelectedDate property of datepicker #2 and it sets the highlighted calendar date (which is correct), but the textbox also displays the date and I need the textbox to continue to stay blank until a date is actually selected from the calendar popup.

Is what I'm asking possible?  I've searched the forums high and low, but can't find my answer.  I thought for sure somebody has ran into this recently. 

I'm using v2014.1.225.45.

Thanks,
Rob

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 06 Feb 2015, 01:03 PM
Hello Rob,

You can use the following approach:

ASPX:
<telerik:RadDatePicker runat="server" ID="RadDatePicker1" AutoPostBack="true"></telerik:RadDatePicker>
<telerik:RadDatePicker runat="server" ID="RadDatePicker2"></telerik:RadDatePicker>

C#:
protected void Page_Load(object sender, EventArgs e)
    {
           if (RadDatePicker1.SelectedDate.HasValue)
           {
               RadCalendarDay day = new RadCalendarDay();
               day.Date = RadDatePicker1.SelectedDate.Value;
               day.ItemStyle.BackColor = System.Drawing.Color.Red;
               RadDatePicker2.Calendar.SpecialDays.Add(day);
           }
    }
 
and see if this helps.

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Rob
Top achievements
Rank 1
answered on 06 Feb 2015, 02:34 PM
Hi Maria,

Strangely your code did not work for me, but this code did.  My 2 datepickers share a RadCalendar.  Can you suggest anything else to look for in order to get your code to work for me?  I have the 2 datepickers and calendar ajaxified.

Protected Sub calShared_DayRender(sender As Object, e As Calendar.DayRenderEventArgs) Handles calShared.DayRender
    If dp1.SelectedDate.HasValue AndAlso e.Day.Date = dp1.SelectedDate Then
        Dim currentCell As TableCell = e.Cell
        currentCell.Style("background-color") = "#FFE89C"
        currentCell.Style("border-color") = "#AEAFA1 !important"
    End If
End Sub

Thanks,
Rob
0
Maria Ilieva
Telerik team
answered on 11 Feb 2015, 11:18 AM
Hi,

You can modify my code as follows:

aspx:
<telerik:RadDatePicker runat="server" ID="RadDatePicker1" SharedCalendarID="SharedCalendar1" AutoPostBack="true">   </telerik:RadDatePicker>
<telerik:RadDatePicker runat="server" ID="RadDatePicker2" SharedCalendarID="SharedCalendar1">
</telerik:RadDatePicker>
<telerik:RadCalendar runat="server" ID="SharedCalendar1"></telerik:RadCalendar>

C#:
protected void Page_Load(object sender, EventArgs e)
   {
          if (RadDatePicker1.SelectedDate.HasValue)
          {
              RadCalendarDay day = new RadCalendarDay();
              day.Date = RadDatePicker1.SelectedDate.Value;
              day.ItemStyle.BackColor = System.Drawing.Color.Red;
              SharedCalendar1.SpecialDays.Add(day);
          }
   }

I hope this helps.

Regards,
Maria Ilieva
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Calendar
Asked by
Rob
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Rob
Top achievements
Rank 1
Share this question
or