CalendarDay d = ((DayRenderEventArgs)e).Day; TableCell c = ((DayRenderEventArgs)e).Cell; if ( !d.IsOtherMonth ) c.Controls.Add(new LiteralControl(dr["EventDetails"].ToString()));
If have know about that we are going to use the same functionality again and again, it is better to make it a re-usable component. So here, you are going to extend the capabilities of basic C# Calendar control. The basic requirement of data driven applications is that source of information basically is data store. It can be database, XML File, Excel or anything for that matter. Here we are going to limit our scope and going to implement the EventCalendar with ADO.NET DataTable as the source of data. Let us see the ingredients of this calendar control
1. A class which extends System.Web.UI.WebControls.Calendar
2. The necessary properties :
EventSource : DataTable with Event Details,
EventStartDateColumnName : ColumnName of the Column of the type DateTime in the EventSource, which stores the Start Date associated with Events
EventEndDateColumnName : ColumnName of the Column of the type DateTime in the EventSource, which stores the End Date associated with Events
EventHeaderColumnName : ColumnName of the Column of the type String in the EventSource, which stores the Event Header,
EventDescriptionColumnName: ColumnName of the Column of the type String in the EventSource, which stores the Event Detailed Description,
ShowDescriptionAsToolTip : Boolean to determine whether to display Event Description as Tool Tip or not.
EventForeColor: ColumnName of the Column to specify the Fore ( Font ) Color for the event. We can specify any Color Name which belongs to System.Drawing.Color namespace.
EventBackColor: ColumnName of the Column to specify the Back Color for the event.We can specify any Color Name which belongs to System.Drawing.Color namespace.
3. EventCalendarDayRender Event : Place where the actual logic to show the events in Calendar is implemented
This describes the skeleton for your EventCalendar Class. Refer to the EventCalendar.cs class in the attached demo for complete implementation. By extending the control in such way we can keep the basic features provided along with the new features/capabilities that we need to cater to our requirements.
|Tags: calendar, create|
|Thread Tools||Search this Thread|
|Similar Threads for: "How to create Calendar in C#"|
|Thread||Thread Starter||Forum||Replies||Last Post|
|How to Create Calendar in Excel||Sanju Baba||Windows Software||3||07-01-2012 01:03 PM|
|Cannot Create Multiple Calendar on iCloud?||Jalela||Technology & Internet||7||18-06-2011 09:24 PM|
|Create a calendar always visible on my PC?||migons||Windows Software||5||04-02-2010 10:46 PM|
|How to create calendar add on visual studio||Saaarc||Software Development||3||30-07-2009 03:10 PM|