/
Listing7-2.txt
37 lines (34 loc) · 1.09 KB
/
Listing7-2.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
namespace Chapter7.SharePoint.SimpleCalendarWebPart
{
[ToolboxItemAttribute(false)]
public class SimpleCalendarWebPart : WebPart
{
[WebBrowsable(true),
Category("Calendar Settings"),
WebDisplayName("Number of Months"),
WebDescription("Number of months (1 or more) to display"),
Personalizable(PersonalizationScope.Shared)]
public int NumberOfMonths
{
get { return _numMonths; }
set { _numMonths = Math.Max(1, value); }
}
int _numMonths;
protected override void CreateChildControls()
{
DateTime today = DateTime.Today;
for (int i = 0; i < this.NumberOfMonths; ++i)
{
Calendar cal = new Calendar();
cal.VisibleDate = today.AddMonths(i);
cal.Style[HtmlTextWriterStyle.MarginBottom] = "10px";
this.Controls.Add(cal);
}
}
}
}