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

Control inside CalendarDayTemplates.

4 Answers 90 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Legalia
Top achievements
Rank 1
Legalia asked on 04 Jun 2009, 09:59 AM
Hi,
I am using calendar control with 'CalendarDayTemplates'. it contains some labels inside it. i am creating some special days from dates which are in my DB and assigning DayTemplateID.
and i also want assign text for it from DB.
But i am not able to find Labels in side 'CalendarDayTemplates' using FindControl or other way.

can you please suggest any solution for this.

4 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 09 Jun 2009, 11:16 AM
Hello Legalia,

When adding server side controls to  your special day templates, the controls' generated markup is added to your cell's Text property, but the server controls themselves are not created and available on the server. Therefore, you cannot find them in the cell wih FindControl(). Only their markup is rendered. Nevertheless, if you register some server-side events declaratively for these controls, their server events are available.

If you still need to modify the special day template on the server, you can do it in RadCalendar's DayRender event, where you can modify the Text property of the e.Cell object representing the current rendering cell. You can even add your own server side controls to the collection, but as the DayRender event is fired after viewstate saving methods on the page, your controls will not be able to maintain their viewstate. At the least, this means that their server events will not be properly registered:

void RadCalendar1_DayRender(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e) 
    if (RadCalendar1.SpecialDays[0].Date == e.Day.Date) 
    { 
        Label label = new Label(); 
        label.Text = "123"
        e.Cell.Controls.Add(label); 
    } 


Greetings,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Derek
Top achievements
Rank 1
answered on 22 Dec 2009, 09:50 PM
I've tried to customize the appearance of special days as well. I have a couple of suggestions that I'd find very valuable;

  • Include the ability to keep the calendar day displayed, via a simple T/F setting
  • Include the ability to add things to the day display for special days. For example, if I use a datareader to add special dates to my calendar, provide the option to add an object, or even to modify a standard property (i.e. TEXT) when the day is being added
  • For that matter, provide the ability to attach a data source directly to a calendar for special days

I used to use the MX Kollection for events-type calendars, which made it very easy, but there's nothing comparable in the asp.net world -- at least not yet!
0
Veli
Telerik team
answered on 23 Dec 2009, 10:19 AM
Hi Derek,

If I understand you correctly, you need some functionality to bind the special days collection of RadCalendar to a data source. While this is not available off-the-shelf in RadCalendar, I do not see any obstacles for you to simply query your data source, iterate over the result and create a special day for each data item, setting it up according to your data values.

Regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Derek
Top achievements
Rank 1
answered on 23 Dec 2009, 01:00 PM
I just had a look at the Scheduler component, and it seems that the functionality I need is already in there.
Tags
Calendar
Asked by
Legalia
Top achievements
Rank 1
Answers by
Veli
Telerik team
Derek
Top achievements
Rank 1
Share this question
or