深入浅出ASP.NET程序设计-源代码 书籍语言: 简体中文 书籍类型: 程序设计 授权方式: 免费软件 书籍大小: 627 KB

源代码在线查看: ch09-02-07.aspx

软件大小: 628 K
上传用户: bandagemaster
关键词: 书籍 ASP 627 NET
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				Ch09-02-07.aspx ValidationSummary控件
				
				     Sub Button1_Click(Obj As Object, e As EventArgs)
				         If Page.IsValid Then
				            Show1.Text = "姓名:" & UserName.Text
				            Show2.Text = "身份证号验证通过!"
				         Else
				            Show1.Text = ""
				       End If 
				    End Sub
				    ' 身份证号验证程序
				     Sub IDNo_Check(Obj As Object, e As ServerValidateEventArgs)
				        Dim intA As Integer , Sums As Long
				        Dim strTemp As String, Position As Integer
				        Dim IDCode() As Integer = {10,11,12,13,14,15,16,17,18, _
				                                      19,20,21,22,23,24,25,26,27, _
				                                      28,29,30,31,32,33,34,35}
				       Dim CodeChar As String = "ABCDEFGHJKLMNPQRSTUVXYWZIO"
				        strTemp = uCase(e.Value.substring(0 ,1))
				        Show1.Text = strTemp
				        Position = Instr(1, CodeChar ,uCase(e.Value.substring(0 ,1)))
				        strTemp = IDCode(Position-1)& mid(e.Value, 2)
				        ' strTemp 已经是11码的身份证号
				        For intA = 2 To Len(strTemp) - 1 
				            Sums += Int32.Parse(Mid(strTemp , intA , 1)) * (11-intA)
				        Next
				        Sums += Int32.Parse(mid(strTemp , 1, 1))
				        Sums += int32.Parse(Right(strTemp,1))
				       If Sums Mod 10 = 0 Then
				           e.IsValid = True
				       Else
				             e.IsValid = False
				        End If
				     End Sub
				
				
				
				ValidationSummary控件
				
				姓名:
				
								       ControlToValidate="UserName" Display="Dynamic"
				       ErrorMessage="必需输入姓名!"
				       Runat="Server" />
				
				身份证号:
				
								       ControlToValidate="IDNo" Display="Dynamic"
				       ErrorMessage="必需输入身份证号!"
				       Runat="Server" />
				
								       OnClick="Button1_Click" Runat="Server" />
								       ControlToValidate="IDNo" Display="Dynamic"
				       ValidationExpression="[A-Za-z]{1,}[0-9]{9}"
				       ErrorMessage="身份证号格式错误!"
				       Runat="Server"/>
								       ControlToValidate="IDNo" Display="Dynamic"
				       OnServerValidate="IDNo_Check"
				       ErrorMessage="身份证号输入错误!"
				       Runat="server" />
								       HeaderText="验证错误摘要信息:"
				       DisplayMode="BulletList" Runat="Server" />
								       BorderColor="#FF8888" Runat="Server" />
								       BorderColor="#FF8888" Runat="Server" />
				
				
				
							

相关资源