Search | Contact | Link To Us  

      ASP.NET      

ASP.NET
Dev Environment
Web Forms
Web Controls
ADO .NET
Web User Controls
Deployment
XML Web Services
ASP.NET Feedback Form
Resources
Discussions
VB .NET
About



Advertisement


     HomeASP.NETWeb Controls> Calendar 

Calendar

The Calendar Web server control displays a single month calendar that allows the user to select a date and move to the next or previous month. By default, this control displays the name of the current month, day headings for the days of the weeks, days of the month and arrow characters for navigation to the previuos or next month. The class hierarchy for this control is as follows:

Object
 Control
  WebControl
   Calendar

Calendar Event

The default event of the Calendar control is the SelectionChanged event which looks like this in code:

Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object,_
ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged

'implementation omitted

End Sub

Notable properties

Notable properties of this control that set it's style are as follows:

DayHeaderStyle: Sets style for the days of the week
DayStyle: Sets styles for the dates in a month
NextPrevStyle: Sets style for the navigation controls
OtherMonthStyle: Sets style for the dates that are not in the displayed month
SelectedDayStyle: Sets style for the selected date
SelectorStyle: Sets style for the for week and month selection column
TitleStyle: Sets style for the title
TodayDayStyle: Sets style for today's date
WeekendDayStyle: Sets style for weekend dates

In addition to the properties mentioned above there are some more properties than can be set to control different parts of the calendar. They are as follows:

ShowDayHeader: Shows or hides the days of the week
ShowGridLines: Shows or hides grid lines
ShowNextPrevMonth: Shows or hides the navigation controls to the next or previous month
ShowTitle: Shows or hides the title

Other properties are as follows:

CellPadding: Gets/Sets the space used for cell padding in the calendar
CellSpacing: Gets/Sets the space between cells in the calendar
DayNameFormat: Gets/Sets the day of the week's name format
FirstDayOfWeek: Gets/Sets the day of the week displayed in the first column
NextMonthText: Gets/Sets the text for next month navigation control
NextPrevFormat: Gets/Sets the format for the next and previous month navigation controls
OtherMonthDayStyle: Gets the style for the days not displyed in current month
PrevMonthText: Gets/Sets the text for previous month navigation control
SelectedDate: Gets/Sets the selected date
SelectedDates: Gets a collection of DateTime objects for the selected dates
SelectionMode: Gets/Sets the date selection mode determining if you can select a day, a week, or a month
SelectMonthText: Gets/Sets the text for the month selection element
SelectWeekText: Gets/Sets the text for week selection element
TitleFormat: Gets/Sets the format for the title
TodaysDate: Gets/Sets today's date
VisibleDate: Gets/Sets a date making sure it's visible

Calendar Sample

Drag a Calendar and a TextBox control on to the form. The following code will display the date selected from the Calendar control in the TextBox. The code looks like this:

Private Sub Calendar1_SelectionChanged(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
TextBox1.Text = Calendar1.SelectedDate
End Sub

You can test the above sample below.

Live Code Demo


<August>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456


  Privacy Policy | Terms of Use | Site Map | Contact

  © 2004-2007 Startvbdotnet.com. All rights reserved.