<%@ Page Language="C#" %>
<HTML>
<body>
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
DepartureDate.SelectedDate = System.DateTime.Today;
}
void SearchButton_Click(object Sender, EventArgs e)
{
if(DepartureDate.SelectedDate <= System.DateTime.Today)
ResultLabel.Text = "You must selected a Departure Date in the future.";
else if(ReturnDate.SelectedDate < DepartureDate.SelectedDate)
ResultLabel.Text = "Return Date must follow the Departure Date.";
else
ResultLabel.Text = "Departing on " + DepartureDate.SelectedDate.ToShortDateString() +
" and returning on " + ReturnDate.SelectedDate.ToShortDateString();
}
</script>
<form runat="server" ID="Form1">
<h1>Find a Flight</h1>
<table>
<tr>
<td>Departure Date</td>
<td><asp:Calendar ID="DepartureDate" Runat="server">
<DayStyle Font-Size="X-Small"></DayStyle>
<TitleStyle Font-Bold="True"></TitleStyle>
</asp:Calendar></td>
</tr>
<tr>
<td>Return Date</td>
<td><asp:Calendar ID="ReturnDate" Runat="server">
<DayStyle Font-Size="X-Small"></DayStyle>
<TitleStyle Font-Bold="True"></TitleStyle>
</asp:Calendar></td>
</tr>
</table>
<asp:Button ID="SearchButton" Runat="server" Text="Search" OnClick="SearchButton_Click" />
<br>
<asp:Label ID="ResultLabel" Runat="server" />
</form>
</body>
</HTML>
|