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

4 posts, 0 answers
  1. Rob
    Rob avatar
    115 posts
    Member since:
    Aug 2012

    Posted 03 Feb 2015 Link to this post

    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
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 06 Feb 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rob
    Rob avatar
    115 posts
    Member since:
    Aug 2012

    Posted 06 Feb 2015 Link to this post

    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
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 11 Feb 2015 Link to this post

    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.

     
Back to Top