Here's one way to do that. You can read the explanation in the inline
comments.
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
' By Ken Cox - June 17/2004
' Shows the first day of the month as the first day of
' the week in the calendar
' Hide the next/previous months
Calendar1.ShowNextPrevMonth = False
' Create a CultureInfo object for Canada
' (Canadian date format is "dd/MM/yyyy")
Dim MyCultureInfo As System.Globalization.CultureInfo
MyCultureInfo = New System.Globalization.CultureInfo("en-CA")
' Build a date string using the first day of the month,
' the current month and current year
Dim dtString As String = "01/" & _
Now.Month.ToString & "/" & Now.Year.ToString
' Convert the string into a datetime according to the culture
Dim dt As DateTime = DateTime.Parse(dtString, MyCultureInfo)
' Set the calendar's first day of week to the
' First day of the week of this month
Calendar1.FirstDayOfWeek = dt.DayOfWeek
' Set the calendar to show this month and day
Calendar1.TodaysDate = Now
Calendar1.VisibleDate = Now
End Sub
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 = " "
End If
End Sub
Does this help?
Ken
Microsoft MVP [ASP.NET]
"bb" <bb**@t.osix.net> wrote in message
news:uU**************@TK2MSFTNGP11.phx.gbl...
any way to prevent displaying the previous and next months in the calendar
control?
i have tried just blanking the text out in the dayrender IsOtherMonth and
also dynamically changing the FirstDayOfWeek to day 1 of the month. but
neither works properly. (the boxes still appear just with no text in them)
i want the calendar to start on day 1 of month and end on Day 31 (with
acceptable trailing blanks between day 31 and the end of that week.
--
------------------------
Think your smart?
Prove your programming power @ the OSI Geek Challenges
http://www.osix.net
------------------------