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

OnDayRender event not working on month change

3 Answers 114 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
shaik Mohammed
Top achievements
Rank 1
shaik Mohammed asked on 27 Oct 2015, 03:43 PM

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

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 28 Oct 2015, 11:26 AM
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
0
shaik Mohammed
Top achievements
Rank 1
answered on 28 Oct 2015, 12:32 PM

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
0
Accepted
Konstantin Dikov
Telerik team
answered on 29 Oct 2015, 11:37 AM
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
Tags
DatePicker
Asked by
shaik Mohammed
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
shaik Mohammed
Top achievements
Rank 1
Share this question
or