Calendar Creation

  • Thread starter Thread starter Mark
  • Start date Start date
M

Mark

Hi,

I'm interested in creating a page that display all 12 months in
mini-style calendars. In the past i've done it with tables and asp,
however i was interested to know if the asp.net calendar control would
be better used? If so can you set 12 separate calendar controls to the
12 months?


On another note is there a way to get a int of the day the month
starts on, to skip forward to? Previously i've done it in asp with:

var d = new Date();
d.setDate(1); d.setMonth(m); d.setYear(y);

for(x=0;x<d.getDay();x++) { //skips unrequired cells
Response.Write('<td>&nbsp;</td>'); intLoop++; skipWeekend++;
}

any thing simlar to the .getDay() call in asp.net?

thanks
 
Hi Mark,

Adding calendars to a page on the fly is very easy. Just put a placeholder
on the aspx page and in the load event loop through and add as many
calendars as you need. Here's an example:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim cal As Calendar
Dim dt As Date
Dim intMonth As Integer
For intMonth = 0 To 11
cal = New Calendar
dt = New Date
dt = Now
cal.VisibleDate = dt.AddMonths(intMonth)
PlaceHolder1.Controls.Add(cal)
Next
End Sub


<form id="Form1" method="post" runat="server">
<asp:PlaceHolder id="PlaceHolder1" runat="server"></asp:PlaceHolder>
</form>

Does this help?

Ken
Microsoft MVP [ASP.NET]
 
Fantastic thanks very much, was exactly what i was looking for. I'll
just have to look up how to manipulate placeholders now, so i can get
them sitting in a nice grid.

finaly code below:

Calendar cal = new Calendar();
DateTime dt = new DateTime();
//int intMonth = 0;
for (int intMonth=0;intMonth<12;intMonth++)
{ //intMonth = 0 To 11
cal = new Calendar();
dt = DateTime.Now;
//dt = Now;
cal.VisibleDate = dt.AddMonths(intMonth-1);
PlaceHolder1.Controls.Add(cal);
}
 
Back
Top