Click here to Skip to main content
13,194,103 members (49,391 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 24 Apr 2007

customize Calendar Control

, 24 Apr 2007
Rate this:
Please Sign up or sign in to vote.
customize Calendar Control to add Day Information and day wise formating.
Screenshot - image.jpg


Customize calendar control to add day wise information and formating.

Using the code


<asp:Calendar ID="Calendar1" runat="server" BackColor="White"
        BorderColor="Black" Font-Names="Verdana" Font-Size="9pt"
        ForeColor="Black" Height="250px" NextPrevFormat="ShortMonth"
        Width="330px" BorderStyle="Solid" CellSpacing="1"

        <SelectedDayStyle BackColor="#333399" ForeColor="White" />
        <TodayDayStyle BackColor="#999999" ForeColor="White" />
        <DayStyle BackColor="#CCCCCC" />
        <OtherMonthDayStyle ForeColor="#999999" />
        <NextPrevStyle Font-Size="8pt" ForeColor="White" Font-Bold="True" />
        <DayHeaderStyle Font-Bold="True" Font-Size="8pt" ForeColor="#333333"
            Height="8pt" />
        <TitleStyle BackColor="#333399" Font-Bold="True"
            Font-Size="12pt" ForeColor="White"
            Height="12pt" BorderStyle="Solid" />

Code Behind:

//array for 12 months and 31 days
string[,] schedDay = new string[13, 32];

protected void Page_Load(object sender, EventArgs e)
    // Prepare day(schedule) list before using it.
    schedDay[1, 1] = "1st  Jan";
    schedDay[1, 14] = "KiteDay";
    schedDay[2, 14] = "(?@#$%^&)";
    schedDay[3, 18] = "Don't Know";
    schedDay[4, 1] = "Fool Day";
    schedDay[4, 15] = "MMMMM";
    schedDay[5, 2] = "Don't Know";
    schedDay[6, 8] = "My Day";
    schedDay[7, 21] = "21th  Jul";
    schedDay[8, 11] = "11 - Aug";
    schedDay[9, 18] = "Sep -18";
    schedDay[10, 6] = "LLLFKKKFK";
    schedDay[11, 11] = "11 - 11";
    schedDay[12, 31] = "The - End";


protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    CalendarDay day = (CalendarDay)e.Day;
    TableCell cell = (TableCell)e.Cell;

    // Check day being rendered is of given month or other.
    // It is required because calander display you some day of previous month
    // and next moth.
    if (!day.IsOtherMonth)
        String dayStr = schedDay[day.Date.Month, day.Date.Day];
        if (dayStr != null)
            // Format the Cell
            cell.BackColor = System.Drawing.Color.Tan;

            //Write some description about day
            cell.Controls.Add(new LiteralControl("<BR>" + dayStr));

By : Paresh [ ]


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 3 Pin
pufo20-Mar-11 23:29
memberpufo20-Mar-11 23:29 
GeneralNice Idea - I suggest a nice enhancement Pin
Cody_213-May-07 3:41
memberCody_213-May-07 3:41 
GeneralRe: Nice Idea - I suggest a nice enhancement Pin
rochana_bg3-May-07 12:37
memberrochana_bg3-May-07 12:37 
GeneralRe: Nice Idea - I suggest a nice enhancement Pin
Cody_213-May-07 12:42
memberCody_213-May-07 12:42 
GeneralRe: Nice Idea - I suggest a nice enhancement [modified] Pin
Cody_214-May-07 4:37
memberCody_214-May-07 4:37 
Thanks so much for the response. I think I see where I have to make these mods now. Looks like I need to add an addtional item to the array that holds the URL that I want them to be able go to when they click on a speicifc date that has something in it...

-- modified at 12:14 Friday 4th May, 2007

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171018.2 | Last Updated 25 Apr 2007
Article Copyright 2007 by pbp_286
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid