Home All Groups Group Topic Archive Search About
Author
4 Oct 2006 7:49 PM
Chris Beres
Greetings,

By default the calendar control displays not only the current month, but
also the days from the previous and the next month (6 weeks total).  Is there
a way to prevent days from other months from showing up on the calendar? 
Example: If the user selects January 2007, I don't want days displayed from
December and February.

I hope that makes sense.

Thanks in advance for your help,

Chris

Here's what I got from the MSDN help:

The Calendar control displays the dates for one month at a time, with a
total of six weeks appearing at once. The control supports several types of
dates, which are described in the following table.

Author
4 Oct 2006 9:20 PM
Tony Girgenti
Hello Chris.

It took me some time to figure this out.

It's the OtherMonthDayStyle properties.

Good luck.
Tony

Show quoteHide quote
"Chris Beres" <ChrisBe***@discussions.microsoft.com> wrote in message
news:1A1FAD2E-21D0-4EE0-B1CF-76888C7F4CB6@microsoft.com...
> Greetings,
>
> By default the calendar control displays not only the current month, but
> also the days from the previous and the next month (6 weeks total).  Is
> there
> a way to prevent days from other months from showing up on the calendar?
> Example: If the user selects January 2007, I don't want days displayed
> from
> December and February.
>
> I hope that makes sense.
>
> Thanks in advance for your help,
>
> Chris
>
> Here's what I got from the MSDN help:
>
> The Calendar control displays the dates for one month at a time, with a
> total of six weeks appearing at once. The control supports several types
> of
> dates, which are described in the following table.
Author
6 Oct 2006 4:24 AM
Ken Cox [Microsoft MVP]
Hi Chris,

You can use the DayRender to check if the day is from another month
(IsOtherMonth ) and if so, substitute a space character.

Check out the code below and let us know if this helps?

Ken
Microsoft MVP [ASP.NET]


<%@ page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Private Sub Calendar1_DayRender _
         (ByVal sender As Object, _
          ByVal e As System.Web.UI. _
          WebControls.DayRenderEventArgs) _
          Handles Calendar1.DayRender
        If e.Day.IsOtherMonth Then
            e.Cell.Text = "&nbsp;"
        End If
    End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:calendar id="Calendar1" runat="server"></asp:calendar>
        </div>
    </form>
</body>
</html>

Show quoteHide quote
"Chris Beres" <ChrisBe***@discussions.microsoft.com> wrote in message
news:1A1FAD2E-21D0-4EE0-B1CF-76888C7F4CB6@microsoft.com...
> Greetings,
>
> By default the calendar control displays not only the current month, but
> also the days from the previous and the next month (6 weeks total).  Is
> there
> a way to prevent days from other months from showing up on the calendar?
> Example: If the user selects January 2007, I don't want days displayed
> from
> December and February.
>
> I hope that makes sense.
>
> Thanks in advance for your help,
>
> Chris
>
> Here's what I got from the MSDN help:
>
> The Calendar control displays the dates for one month at a time, with a
> total of six weeks appearing at once. The control supports several types
> of
> dates, which are described in the following table.