验证控件
Posted 晨落梦公子
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了验证控件相关的知识,希望对你有一定的参考价值。
RequiredFielValidator(验证是否输入信息):
代码:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 8 public partial class RequiredFieldValidatorControls : System.Web.UI.Page 9 { 10 protected void Page_Load(object sender, EventArgs e) 11 { 12 13 } 14 protected void btnSubmit_Click(object sender, EventArgs e) 15 { 16 // IsValid 判断有效 17 if ((rfvName.IsValid == true) && (rfvPwd.IsValid == true)){ 18 lab.Text = "恭喜通过验证"; 19 } 20 } 21 }
*..* IsValid 判断有效
相关设置:
RangeValidator(范围验证控件)
代码:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 8 public partial class RangeValidatorControls : System.Web.UI.Page 9 { 10 protected void Page_Load(object sender, EventArgs e) 11 { 12 13 } 14 protected void btnSubmit_Click(object sender, EventArgs e) 15 { 16 if (rvAge.IsValid == true) { 17 lab.Text = "您输入的年龄" + txtAge.Text + "通过验证!"; 18 } 19 } 20 }
相关设置:
其他同上。
RegularExpressionValidator(正则表达式验证)
代码:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 8 public partial class RegularExpressionValidatorControls : System.Web.UI.Page 9 { 10 protected void Page_Load(object sender, EventArgs e) 11 { 12 13 } 14 protected void btnSubmit_Click(object sender, EventArgs e) 15 { 16 if ((revID.IsValid == true) && (revPhone.IsValid == true)) { 17 lab.Text = "您输入的身份证号码" + txtID.Text + "和电话号码" + txtPhone.Text + "通过验证"; 18 } 19 } 20 }
CompareValidator(比较验证)
代码:
1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Web; 5 using System.Web.UI; 6 using System.Web.UI.WebControls; 7 8 public partial class CompareValidatorControls : System.Web.UI.Page 9 { 10 protected void Page_Load(object sender, EventArgs e) 11 { 12 13 } 14 protected void btnSubmit_Click(object sender, EventArgs e) 15 { 16 lab.Text = txtName.Text + "您好! <br>" + "您第一次输入的密码是:" + txtPwd.Text 17 + "<br>" + "您第二次输入的密码是:" + txtPwd2.Text; 18 } 19 }
以上是关于验证控件的主要内容,如果未能解决你的问题,请参考以下文章
c_cpp 快速代码片段,用于在统计(阻止)/ dev / rdsk中的设备时验证fstat64和stat64的行为。
如何在导航控件片段中关闭导航 DrawerLayout onBackPressed
jmeter的Include Controller控件和Test Fragment控件和Module Controller控件