Public Class Sample16
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 ValidationSummary1 As System.Web.UI.WebControls.ValidationSummary
Protected WithEvents bdpArrivalDate As BasicFrame.WebControls.BDPLite
Protected WithEvents RangeValidator2 As BasicFrame.WebControls.RangeValidator
Protected WithEvents RequiredFieldValidator2 As BasicFrame.WebControls.RequiredFieldValidator
Protected WithEvents bdpReturnDate As BasicFrame.WebControls.BDPLite
Protected WithEvents RangeValidator1 As BasicFrame.WebControls.RangeValidator
Protected WithEvents RequiredFieldValidator1 As BasicFrame.WebControls.RequiredFieldValidator
Protected WithEvents CompareValidator1 As BasicFrame.WebControls.CompareValidator
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()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
' Pre fill Arrival and Return dates to Today.
Me.bdpArrivalDate.SelectedDate = DateTime.Today
Me.bdpReturnDate.SelectedDate = DateTime.Today
' User must select a date greater than or equal to today.
Me.RangeValidator1.MinimumDate = DateTime.Today
Me.RangeValidator2.MinimumDate = DateTime.Today
End If
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
If Me.Page.IsValid Then
' Check to see if Arrival Date isNull (DateTime.MinValue).
If Not Me.bdpArrivalDate.IsNull Then ' If it's not null, then create Text for Label.
labelText += "Arrival Date: <strong>" + Me.bdpArrivalDate.SelectedDateFormatted + "</strong><br />"
End If
' Check to see if Return Date isNull (DateTime.MinValue).
If Not Me.bdpReturnDate.IsNull Then ' If it's not null, then create Text for Label.
labelText += "Return Date: <strong>" + Me.bdpReturnDate.SelectedDateFormatted + "</strong><br />"
End If
' Calculate number of nights stay.
Dim nights As Int32 = DateDiff(DateInterval.Day, Me.bdpArrivalDate.SelectedDate, Me.bdpReturnDate.SelectedDate)
labelText += "Length of stay: <strong>" + nights.ToString() + " nights</strong>."
Else
labelText += "Page is Invalid."
End If
Label1.Text = labelText
End Sub
End Class