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

RadCalendar Special Days Problem

4 Answers 214 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
omer
Top achievements
Rank 1
omer asked on 11 Jan 2011, 08:46 AM
Hi to all

this is my code how to generate special days in code behind

private void Page_Load(object sender, EventArgs e)
    {
        var dc =
            new takvimDataContext(
                "Data Source=xxx;");
        var sDays = from tkvm in dc.takvims
                    where
                        tkvm.tarih.Year == RadCalendar1.Calendar.GetYear(RadCalendar1.CalendarView.ViewStartDate)
                    select tkvm;
  
        foreach (var day in sDays)
        {
            var rcd = new RadCalendarDay {Date = day.tarih,TemplateID = "tatil"};
  
  
            RadCalendar1.SpecialDays.Add(rcd);
            var cl = RadCalendar1.Calendar;
                  
        }

and my problem is

 

i cant display specials days numbers in calendar
they are all empty (In template i make red background to specials days to see are they working ?)
when i try to fill them in template

 

<CalendarDayTemplates>
            <telerik:DayTemplate ID="tatil" runat="server">
                <Content>
                  
                    <div style="background-color:Red">
                        <%= RadCalendar1.????????????%>
                    </div>
                </Content>
            </telerik:DayTemplate>
        </CalendarDayTemplates>

How can i show the current date in special days collection ?

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 14 Jan 2011, 12:21 PM
Hi Omer,

Note that the required functionality could not be achieved with RadCalendar special days. The only possible way is to manually add the date to each specific template like this:
<CalendarDayTemplates>
           <telerik:DayTemplate ID="DateTemplate" runat="server">
               <Content>
                   <div class="rcTemplate rcDayDate">
                       1
                   </div>
               </Content>
           </telerik:DayTemplate>


Kind regards,
Maria Ilieva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Maria Ilieva
Telerik team
answered on 14 Jan 2011, 12:21 PM
Hi Omer,

Note that the required functionality could not be achieved with RadCalendar special days. The only possible way is to manually add the date to each specific template like this:
<CalendarDayTemplates>
           <telerik:DayTemplate ID="DateTemplate" runat="server">
               <Content>
                   <div class="rcTemplate rcDayDate">
                       1
                   </div>
               </Content>
           </telerik:DayTemplate>


Kind regards,
Maria Ilieva
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Support@silverbear.com
Top achievements
Rank 1
answered on 28 Jun 2011, 01:51 PM
Actually, there is a way to do this..

In the template, create some tokens to represent day specific data.. like this:-

<CalendarDayTemplates>
           <telerik:DayTemplate ID="DateTemplate" runat="server">
               <Content>
                   <div class="rcTemplate rcDayDate">
                       {DayOfMonth}
                   </div>
               </Content>
           </telerik:DayTemplate>

Then in the DayRender event handler, simply replace tokens based on currently rendered day:-

   protected void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
        {
            // Do a token replace..
            e.Cell.Text = e.Cell.Text.Replace("{DayOfMonth}", e.Day.Date.Day.ToString());
     
        }

I hope that helps anyone who has stumbled accross this problem..

Darrell @ Silverbear
0
Guillaume
Top achievements
Rank 1
answered on 16 Sep 2015, 07:13 PM
Well thank you! You saved my day. It works well.
Tags
Calendar
Asked by
omer
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Support@silverbear.com
Top achievements
Rank 1
Guillaume
Top achievements
Rank 1
Share this question
or