博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
验证控件的使用四( RangeValidator)
阅读量:6800 次
发布时间:2019-06-26

本文共 1582 字,大约阅读时间需要 5 分钟。


 
1
<%
@ Page Language
=
"
C#
"
%>
2
3
<
script runat
=
"
server
"
>
4
protected
void
Page_Load(
object
sender, EventArgs e)
5
{
6
RangeValidator1.MinimumValue
=
DateTime.Now.ToShortDateString();
7
RangeValidator1.MaximumValue
=
DateTime.Now.AddDays(
14
).ToShortDateString();
8
}
9
10
protected
void
Calendar1_SelectionChanged(
object
sender, EventArgs e)
11
{
12
TextBox1.Text
=
Calendar1.SelectedDate.ToShortDateString();
13
}
14
15
protected
void
Button1_Click(
object
sender, EventArgs e)
16
{
17
if
(Page.IsValid)
18
{
19
Label1.Text
=
"
You are set to arrive on:
"
+
TextBox1.Text.ToString();
20
}
21
}
22
</
script
>
23
24
<
html xmlns
=
"
http://www.w3.org/1999/xhtml
"
>
25
<
head id
=
"
Head1
"
runat
=
"
server
"
>
26
<
title
>
Date Validation Check
</
title
>
27
</
head
>
28
<
body
>
29
<
form id
=
"
form1
"
runat
=
"
server
"
>
30
Arrival Date:
31
<
asp:TextBox ID
=
"
TextBox1
"
runat
=
"
server
"
></
asp:TextBox
>&
nbsp;
32
<
asp:RangeValidator ID
=
"
RangeValidator1
"
runat
=
"
server
"
Text
=
"
You must only select a date within the next two weeks.
"
33
ControlToValidate
=
"
TextBox1
"
Type
=
"
Date
"
></
asp:RangeValidator
><
br
/>
34
<
br
/>
35
Select your arrival date:
<
br
/>
36
<
asp:Calendar ID
=
"
Calendar1
"
runat
=
"
server
"
OnSelectionChanged
=
"
Calendar1_SelectionChanged
"
></
asp:Calendar
>
37
&
nbsp;
38
<
br
/>
39
<
asp:Button ID
=
"
Button1
"
runat
=
"
server
"
Text
=
"
Button
"
OnClick
=
"
Button1_Click
"
/>
40
<
br
/>
41
<
br
/>
42
<
asp:Label ID
=
"
Label1
"
runat
=
"
server
"
></
asp:Label
>
43
</
form
>
44
</
body
>
45
</
html
>

转载地址:http://smuwl.baihongyu.com/

你可能感兴趣的文章
java函数式编程
查看>>
获5.3亿美金融资,亚马逊、红杉入局,自动驾驶“梦之队”Aurora还藏了哪些秘招?...
查看>>
C#-Xamarin利用ZXing.Net.Mobile进行扫码
查看>>
网站有漏洞被攻击篡改了数据该怎么修复解决
查看>>
抖音短视频开发项目跨入社交圈,头条实现社交梦?
查看>>
亲测 | 如何更高效的管理原生微服务应用
查看>>
jQuery UI 自定义样式的日历控件
查看>>
成为优秀UI设计师,必须了解的UI设计规范
查看>>
Memcached源码分析 - LRU淘汰算法(6)
查看>>
数据类型
查看>>
Jenkins 插件之环境变量插件EnvInject(学习笔记十三)
查看>>
PowerShell收集服务器日检报告,并发邮件给指定人员
查看>>
windows命令行删除所有文件和子目录
查看>>
网球机器人入侵火星 从单独工作到团队协作
查看>>
java中多种写文件方式的效率对比实验
查看>>
升级Xcode7之后如果遇到下面的错误
查看>>
浅谈React工作原理
查看>>
计划任务与系统日志管理
查看>>
Spring Security3配置使用
查看>>
升级aws ec2主机配置
查看>>