Select a Range of Dates
You can select a range of dates in your code through calling the Add method of the C1Calendar's C1DateCollection class.
To set the selection to the first week in the month of February 2007, complete the following steps:
1. Add a PlaceHolder control to the .aspx page.
2. Declare the C1.Web.UI.Controls.C1Calendar namespace directive to your code.
Imports C1.Web.UI.Controls.C1Calendar
• C#
using C1.Web.UI.Controls.C1Calendar;
3. Enter the following code in the Page_Load procedure to add C1Calendar with selected dates:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Me.Page.IsPostBack Then
Dim c1calendar As C1Calendar = New C1Calendar()
PlaceHolder1.Controls.Add(c1calendar)
c1calendar.Height = Unit.Pixel(180)
c1calendar.Width = Unit.Pixel(230)
' add selected dates to c1calendar
Dim sdates As C1DateCollection = c1calendar.SelectedDates
sdates.Clear()
sdates.Add(new DateTime(2009,3,1));
sdates.Add(New DateTime(2009,3,2));
sdates.Add(New DateTime(2009,3,3));
sdates.Add(New DateTime(2009,3,4));
sdates.Add(New DateTime(2009,3,5));
sdates.Add(New DateTime(2009,3,6));
sdates.Add(New DateTime(2009,3,7));
End If
End Sub
• C#
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
C1Calendar c1calendar = new C1Calendar();
// add calendar to the Web form
PlaceHolder1.Controls.Add(c1calendar);
c1calendar.Height = Unit.Pixel(180);
c1calendar.Width = Unit.Pixel(230);
// add selected dates to c1calendar
C1DateCollection sdates = c1calendar.SelectedDates;
sdates.Clear();
sdates.Add(new DateTime(2009,3,1));
sdates.Add(new DateTime(2009,3,2));
sdates.Add(new DateTime(2009,3,3));
sdates.Add(new DateTime(2009,3,4));
sdates.Add(new DateTime(2009,3,5));
sdates.Add(new DateTime(2009,3,6));
sdates.Add(new DateTime(2009,3,7));
}
}
This Topic Illustrates the Following:
The selected dates and their styles apply to the first week of March.
|