Imports BasicFrame.WebControls
Public Class Sample13
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents BasicDatePicker1 As BasicFrame.WebControls.BasicDatePicker
Protected WithEvents SpecialDates1 As BasicFrame.WebControls.SpecialDates
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(-16), "Hamlet", True, String.Empty))
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(-2), "Macbeth", True, String.Empty))
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(-1), "King Lear", True, String.Empty))
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(1), "Romeo and Juliet", True, String.Empty))
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(1), "Othello", True, String.Empty))
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(4), "Much Ado About Nothing", True, String.Empty))
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(5), "Twelfth Night", True, String.Empty))
Me.SpecialDates1.Dates.Add(New SpecialDate(DateTime.Today.AddDays(14), "The Merchant of Venice", True, String.Empty))
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim labelText As String = String.Empty
' Check to see if DateTime object isNull (DateTime.MinValue).
If Not Me.BasicDatePicker1.IsNull Then
' Option #1
' .SelectedDateFormatted automatically converts the SelectedDate
' to a string and formats according to the DateFormat.
labelText = "<strong>" + Me.BasicDatePicker1.SelectedDateFormatted + "</strong><br />"
' Option #2
' The SelectedDate could also be converted to a String manually.
' labelText = this.BasicDatePicker1.SelectedDate.ToString("MMMM dd, yyyy");
Else
labelText = "<strong>No Date.</strong><br />"
End If
' If SelectedDate is contained in SpecialDate Collection, then
' print related SpecialDate object to screen.
If Me.SpecialDates1.Dates.Contains(Me.BasicDatePicker1.SelectedDate) Then
Dim specialDate As specialDate
For Each specialDate In Me.SpecialDates1.Dates
' Is SpecialDate happen on the same Day as SelectedDate.
If specialDate.Date.ToShortDateString() = Me.BasicDatePicker1.SelectedDate.ToShortDateString() Then
labelText += "Event Name: <strong>" + specialDate.Text + "</strong><br />"
End If
Next
End If
Label1.Text = "You picked: " + labelText
End Sub
End Class