How to show holidays in a different color in calendar web server control?

Discussion in 'ASP .Net' started by Simon, Jun 19, 2008.

  1. Simon

    Simon Guest

    By default, days in the calendar control are simply displayed as numbers, I
    want to show some days in a different color in this control. What is the
    best way to do that?

    Thanks very much.
    Simon, Jun 19, 2008
    #1
    1. Advertising

  2. Simon

    Munna Guest

    Re: How to show holidays in a different color in calendar web servercontrol?

    Hi

    Do subscribe the DayRender event of the calender control...
    and change your style
    here is a simple code snippet

    protected void Calendar1_DayRender(object sender, DayRenderEventArgs
    e)
    {
    if (e.Day.IsWeekend)
    {
    e.Cell.BackColor = Color.Red;
    }
    }

    Best of luck

    Munna
    www.munna.shatkotha.com
    www.munna.shatkotha.com/blog
    www.shatkotha.com
    Munna, Jun 19, 2008
    #2
    1. Advertising

  3. Hi Simon,

    As for Calendar control, I think the best place to perform the
    customization is using "DayRender" event. In this event, you can get the
    current Cell being rendered. And you can check the DateTime and then do
    some customization on the cell. For example:

    ========================
    Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender

    If e.Day.Date.Day Mod 5 = 1 Then

    e.Cell.BackColor = System.Drawing.Color.Yellow

    End If

    End Sub
    ========================

    For your case, what you need to do is write a function to check whether it
    is holiday based on the DateTime value. Then, chang the background or
    foreground color.

    Hope this helps.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >Reply-To: "Simon" <>
    >From: "Simon" <>
    >Subject: How to show holidays in a different color in calendar web server

    control?
    >Date: Thu, 19 Jun 2008 14:29:00 +0800


    >
    >By default, days in the calendar control are simply displayed as numbers,

    I
    >want to show some days in a different color in this control. What is the
    >best way to do that?
    >
    >Thanks very much.
    >
    >
    Steven Cheng [MSFT], Jun 19, 2008
    #3
  4. Simon

    Simon Guest

    Thank you, Steven. You are always so helpful. Thanks to Munna too.


    "Steven Cheng [MSFT]" <> wrote in message
    news:...
    > Hi Simon,
    >
    > As for Calendar control, I think the best place to perform the
    > customization is using "DayRender" event. In this event, you can get the
    > current Cell being rendered. And you can check the DateTime and then do
    > some customization on the cell. For example:
    >
    > ========================
    > Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
    >
    > If e.Day.Date.Day Mod 5 = 1 Then
    >
    > e.Cell.BackColor = System.Drawing.Color.Yellow
    >
    > End If
    >
    > End Sub
    > ========================
    >
    > For your case, what you need to do is write a function to check whether it
    > is holiday based on the DateTime value. Then, chang the background or
    > foreground color.
    >
    > Hope this helps.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    > --------------------
    >>Reply-To: "Simon" <>
    >>From: "Simon" <>
    >>Subject: How to show holidays in a different color in calendar web server

    > control?
    >>Date: Thu, 19 Jun 2008 14:29:00 +0800

    >
    >>
    >>By default, days in the calendar control are simply displayed as numbers,

    > I
    >>want to show some days in a different color in this control. What is the
    >>best way to do that?
    >>
    >>Thanks very much.
    >>
    >>

    >
    Simon, Jun 20, 2008
    #4
  5. You're welcome Simon,

    Have a nice day!

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------
    >Reply-To: "Simon" <>
    >In-Reply-To: <>
    >Subject: Re: How to show holidays in a different color in calendar web

    server control?
    >Date: Fri, 20 Jun 2008 11:28:41 +0800


    >Thank you, Steven. You are always so helpful. Thanks to Munna too.
    >
    >
    >"Steven Cheng [MSFT]" <> wrote in message
    >news:...
    >> Hi Simon,
    >>
    >> As for Calendar control, I think the best place to perform the
    >> customization is using "DayRender" event. In this event, you can get the
    >> current Cell being rendered. And you can check the DateTime and then do
    >> some customization on the cell. For example:
    >>
    >> ========================
    >> Protected Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As
    >> System.Web.UI.WebControls.DayRenderEventArgs) Handles Calendar1.DayRender
    >>
    >> If e.Day.Date.Day Mod 5 = 1 Then
    >>
    >> e.Cell.BackColor = System.Drawing.Color.Yellow
    >>
    >> End If
    >>
    >> End Sub
    >> ========================
    >>
    >> For your case, what you need to do is write a function to check whether

    it
    >> is holiday based on the DateTime value. Then, chang the background or
    >> foreground color.
    >>
    >> Hope this helps.
    >>
    >> Sincerely,
    >>
    >> Steven Cheng
    >>
    >> Microsoft MSDN Online Support Lead
    >>
    >>
    >> Delighting our customers is our #1 priority. We welcome your comments and
    >> suggestions about how we can improve the support we provide to you.

    Please
    >> feel free to let my manager know what you think of the level of service
    >> provided. You can send feedback directly to my manager at:
    >> .
    >>
    >> ==================================================
    >> Get notification to my posts through email? Please refer to
    >>

    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    >> ications.
    >>
    >> Note: The MSDN Managed Newsgroup support offering is for non-urgent

    issues
    >> where an initial response from the community or a Microsoft Support
    >> Engineer within 1 business day is acceptable. Please note that each

    follow
    >> up response may take approximately 2 business days as the support
    >> professional working with you may need further investigation to reach the
    >> most efficient resolution. The offering is not appropriate for situations
    >> that require urgent, real-time or phone-based interactions or complex
    >> project analysis and dump analysis issues. Issues of this nature are best
    >> handled working with a dedicated Microsoft Support Engineer by contacting
    >> Microsoft Customer Support Services (CSS) at
    >> http://msdn.microsoft.com/subscriptions/support/default.aspx.
    >> ==================================================
    >> This posting is provided "AS IS" with no warranties, and confers no
    >> rights.
    >> --------------------
    >>>Reply-To: "Simon" <>
    >>>From: "Simon" <>
    >>>Subject: How to show holidays in a different color in calendar web server

    >> control?
    >>>Date: Thu, 19 Jun 2008 14:29:00 +0800

    >>
    >>>
    >>>By default, days in the calendar control are simply displayed as numbers,

    >> I
    >>>want to show some days in a different color in this control. What is the
    >>>best way to do that?
    >>>
    >>>Thanks very much.
    >>>
    >>>

    >>

    >
    >
    Steven Cheng [MSFT], Jun 20, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bob

    State holidays

    Bob, Dec 15, 2003, in forum: ASP .Net
    Replies:
    8
    Views:
    673
  2. Ed Jay
    Replies:
    2
    Views:
    430
    Neredbojias
    Dec 21, 2005
  3. Happy Holidays

    , Dec 25, 2003, in forum: Ruby
    Replies:
    4
    Views:
    91
    Simon Strandgaard
    Dec 26, 2003
  4. Daniel Berger

    Detecting holidays

    Daniel Berger, Jan 2, 2007, in forum: Ruby
    Replies:
    21
    Views:
    297
    Daniel Berger
    Jan 5, 2007
  5. Kamaljeet Saini
    Replies:
    0
    Views:
    412
    Kamaljeet Saini
    Feb 13, 2009
Loading...

Share This Page