OnDayRender event not working on month change

4 posts, 1 answers
  1. shaik Mohammed
    shaik Mohammed avatar
    12 posts
    Member since:
    Apr 2014

    Posted 27 Oct 2015 Link to this post

    Hi

    I'm adding custom special day using OnDayRender. this event is not working when i change or navigate to any other month.

    here is my code

    ASPX:

    <telerik:RadDatePicker Calendar-DayNameFormat="Shortest" Calendar-ShowOtherMonthsDays="false" DateInput-ReadOnly="true" DatePopupButton-ImageUrl="/images/calander_icon.gif" DatePopupButton-HoverImageUrl="/images/calander_icon.gif"
                                                                      ID="rdpDeliveryDate" OnLoad="rdpDeliveryDate_Load"  runat="server" >
                                                                     <Calendar ID="Calendar1" runat="server" ShowRowHeaders="false"  OnDayRender="dayRender"  ShowFastNavigationButtons="false" FirstDayOfWeek="Sunday"></Calendar>
                                                                 </telerik:RadDatePicker>
     

    CS:

    protected void rdpDeliveryDate_Load(object sender, EventArgs e)
           {
               (sender as RadDatePicker).MinDate = CommonLogic.CurrentGccTime().Date;
           }
     

    protected void dayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
            {
     
    if (e.Day.Date.DayOfWeek == DayOfWeek.Wednesday|| e.Day.Date.DayOfWeek == DayOfWeek.Sunday)
            {
                            // clear the default cell content (anchor tag) as we need to disable the hover effect for this cell
                            e.Cell.Text = "";
                            e.Cell.CssClass = "rcOutOfRange"; //set new CssClass for the disabled calendar day cells (e.g. look like other month days here)
     
                            // render a span element with the processed calendar day number instead of the removed anchor -- necessary for the calendar skinning mechanism
                            Label label = new Label();
                            label.Text = e.Day.Date.Day.ToString();
                            e.Cell.Controls.Add(label);
                            e.Cell.ToolTip = "Day Off";
     
                            RadCalendarDay dayoff = new RadCalendarDay();
                            dayoff.Date = e.Day.Date;
                            dayoff.IsSelectable = false;
                            dayoff.IsDisabled = true;
                            dayoff.ItemStyle.CssClass = "rcOutOfRange";
     
                            cln.SpecialDays.Add(dayoff);
                             
                        }
    }

    I'm using  Version 2015.2.826.45,

    Visual studio 2012.

    Please help me

    Appreciate for Quick and best Response

     

    Yasin

  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 28 Oct 2015 Link to this post

    Hello Yasin,

    In order for the OnDayRender event to be fired when you change the month view you need to set the AutoPostBack property of the calendar to "true". By default, changing the month view will be handled on client-side and no server-side event will be fired.

    Hope this helps.


    Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shaik Mohammed
    shaik Mohammed avatar
    12 posts
    Member since:
    Apr 2014

    Posted 28 Oct 2015 in reply to Konstantin Dikov Link to this post

    Hi,

    If i set AutoPostBack="true" then i try to navigate month. with that full page post back  is  happening and calendar reloading.

    i'm using DatePicker inside repeater using with  update panel.

    please see my code below:

       <asp:UpdatePanel ID="updMain" runat="server">
                      <ContentTemplate>
    <asp:Repeater ID="rptShops" OnItemDataBound="rptShops_ItemDataBound" runat="server">
                      <ItemTemplate>
    <telerik:RadDatePicker Calendar-DayNameFormat="Shortest"  DateInput-ReadOnly="true" DatePopupButton-ImageUrl="/images/calander_icon.gif" DatePopupButton-HoverImageUrl="/images/calander_icon.gif"
                                                                       ID="rdpDeliveryDate" OnLoad="rdpDeliveryDate_Load"  runat="server" >
                                                                      <Calendar ID="Calendar1" runat="server"  AutoPostBack="true" ShowRowHeaders="false"  OnDayRender="dayRender"  ShowFastNavigationButtons="false" FirstDayOfWeek="Sunday"></Calendar>
                                                                  </telerik:RadDatePicker>
      
                      </ItemTemplate>
     </asp:Repeater>
     </ContentTemplate>
                  </asp:UpdatePanel>

    Yasin
  5. Answer
    Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 29 Oct 2015 Link to this post

    Hi Yasin,

    Your observations are correct and it will not be possible to enable AJAX for the RadCalendar control in this scenario, because it will be rendered in a popup element placed outside the form element.

    The only thing that I could suggest for avoiding the full postback in this scenario is to handle the client-side OnDayRender event instead:
    <Calendar ID="Calendar1"  runat="server" ClientEvents-OnDayRender="dataRender" ...

    And here is the help article for the OnDayRender event:

    Best Regards,
    Konstantin Dikov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top