Advertisement
Advertisement
| 06.24.2008 at 11:21AM PDT, ID: 23512025 |
|
[x]
Attachment Details
|
||
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: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: |
Partial Class Default2
Inherits System.Web.UI.Page
Dim holidays(12, 31) As String
Sub Calendar1_DayRender(ByVal sender As Object, ByVal e As DayRenderEventArgs)
Dim d As CalendarDay
Dim c As TableCell
d = e.Day
c = e.Cell
If d.IsOtherMonth Then
c.Controls.Clear()
Else
Try
Dim Hol As String
Hol = holidays(d.Date.Month, d.Date.Day)
If Hol <> "" Then
c.Controls.Add(New LiteralControl("<br>" + Hol))
End If
Catch exc As Exception
Response.Write(exc.ToString())
End Try
End If
End Sub
Sub Date_Selected(ByVal sender As Object, ByVal e As EventArgs) Handles Calendar1.SelectionChanged
If pnlCustomEntry.Visible = False Then
pnlCustomEntry.Visible = True
End If
Label1.Text = "Selected date is: " + Calendar1.SelectedDate.ToShortDateString
Label2.Text = Calendar1.SelectedDate.ToShortDateString
Label3.Text = holidays(Calendar1.SelectedDate.Date.Month, Calendar1.SelectedDate.Date.Day)
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim temp As Object = "New Year's Day"
holidays(1, 1) = temp
holidays(1, 26) = "Australia Day"
holidays(2, 2) = "Groundhog Day"
holidays(2, 14) = "Valentine's Day"
holidays(3, 17) = "St. Patrick's Day"
holidays(4, 1) = "April Fool's Day"
holidays(5, 1) = "May Day"
holidays(6, 15) = "My Birthday"
holidays(7, 15) = "My Anniversary"
holidays(8, 15) = "My Mother's Birthday"
holidays(9, 24) = "Autumnal Equinox"
holidays(12, 26) = "Boxing Day"
' this line sets the calendar to start on January of next year
Calendar1.VisibleDate = New Date(Now.Year + 1, 1, 1)
End Sub
Protected Sub Calendar1_VisibleMonthChanged(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MonthChangedEventArgs) Handles Calendar1.VisibleMonthChanged
pnlCustomEntry.Visible = False
'This portion keeps the calendar restricted to next year
If Calendar1.VisibleDate.Year = Now.Year Then
Calendar1.VisibleDate = New Date(Now.Year + 1, Calendar1.VisibleDate.Month, Calendar1.VisibleDate.Day)
End If
End Sub
Protected Sub butCustomAddEntry_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles butAddCustomEntry.Click
holidays(Calendar1.SelectedDate.Date.Month, Calendar1.SelectedDate.Date.Day) = txtCustomEntry.Text()
End Sub
End Class
|