473,387 Members | 1,573 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Calendar Control dont display Other Month

bb
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
------------------------
Nov 18 '05 #1
2 6959
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
------------------------


Nov 18 '05 #2
bb
Ken Cox [Microsoft MVP] wrote:
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 = "&nbsp;"
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
------------------------


Thanks .. i have tried this,

but it doesnt seem to display correctly for me, i implement your code,
and now i get blank row first line in the calendar and the first entry
on the second line is correctly the first of the month.

anyway to get rid of that blank row??

i have tried setting the othermonth to both nbsp and clearing the cell.
the problem is i dont want a blank cell! i want the first day of the
month to appear as the very first 1,1 cell in the calendar

thanks in advance

db

--
------------------------
Think your smart?
Prove your programming power @ the OSI Geek Challenges
http://www.osix.net
------------------------
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Stimp | last post by:
preferably one that when clicked can update three date dropdowns (day, month, year) like http://www.visitdublin.com/carhire/avis.asp Don't mind paying for the file... anyone seen something...
27
by: Dino M. Buljubasic | last post by:
I'd like to build a calendar displaying all days in a month in a grid so that when I click on the header of a square representing a day of month, I can add a new meeting etc. I know that .net...
4
by: Jason Chan | last post by:
How can I get the month and year a calendar control current displaying? My problem is I want to load a list of event to a calendar so that it display difference style if there a event for a day....
3
by: Peter | last post by:
Is there anyway to make the System.Web.UI.WebControls.Calendar to display only Month Name and Year, like: January, 2006 February, 2006 ..... .... .... ....
6
by: Sridhar | last post by:
Hi, I need to display a calendar that shows all the months of an year. In that, I need to show different colors for certain events. I know how to display a calendar for a certain month but I am...
1
by: Jessica Weiner | last post by:
I have an ASP .NET web application and I am using the calender control to display the month view and some events that are scheduled to happen during the month. Whenever the user selects a month,...
14
by: magmike | last post by:
Can I do anything with the calendar buttons? I want to display a number on the buttons. I'm using the calendar control on a form that sets a call back date and time. The user can click on the...
0
by: mathewgk80 | last post by:
HI all, I am having popup calendar Javascript code. But i dont know how it is connecting to asp.net code.. I am using asp.net,c#.net and also using 3tier architecture with master page.... I...
1
by: abhishekbrave | last post by:
The code below is opening a calendar on mouse over in the same window. I need the calendar to be opened in new window. Have to fulfill this requirement urgentely so posting the whole code here. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.