Code <% @ Page Language = " C# " %> < script runat = " server " > protected void Page_Load( object sender, EventArgs e) { RangeValidator1.MinimumValue = DateTime.Now.ToShortDateString(); RangeValidator1.MaximumValue = DateTime.Now.AddDays( 14 ).ToShortDateString(); } protected void Calendar1_SelectionChanged( object sender, EventArgs e) { TextBox1.Text = Calendar1.SelectedDate.ToShortDateString(); } protected void Button1_Click( object sender, EventArgs e) { if (Page.IsValid) { Label1.Text = " You are set to arrive on: " + TextBox1.Text.ToString(); } } </ script > < html xmlns = " http://www.w3.org/1999/xhtml " > < head id = " Head1 " runat = " server " > < title > Date Validation Check </ title > </ head > < body > < form id = " form1 " runat = " server " > Arrival Date: < asp:TextBox ID = " TextBox1 " runat = " server " ></ asp:TextBox > < asp:RangeValidator ID = " RangeValidator1 " runat = " server " ErrorMessage = " 必须选择未来两周内的时间 " ControlToValidate = " TextBox1 " Type = " Date " ></ asp:RangeValidator >< br /> < br /> Select your arrival date:< br /> < asp:Calendar ID = " Calendar1 " runat = " server " OnSelectionChanged = " Calendar1_SelectionChanged " ></ asp:Calendar > & nbsp; < br /> < asp:Button ID = " Button1 " runat = " server " Text = " Button " OnClick = " Button1_Click " /> < br /> < br /> < asp:Label ID = " Label1 " runat = " server " ></ asp:Label > </ form > </ body > </ html >
posted @
2009-01-15 14:54
jianlinglo
阅读(
342 )
评论()
编辑
收藏
举报