分类分类
关注+2009-05-29作者:
asp.net 1.1中,有不少验证控件,大大方便了我们,但有的时候,当需要做特殊的验证时,还会觉得不够用的,于是我们可以用自定义验证控件CustomValidator,要使用这个控件,必须在服务端写相应的事件,格式如下:
Sub FunctionName(sender as Object, args as ServerValidateEventArgs) ... End Sub |
<script language="vb" runat="server"> Sub btnSubmit_Click(sender as Object, e as EventArgs) If Page.IsValid then Response.Write("<font color=""red""><i>" & txtPrimeNumber.Text & _ " is, indeed, a good prime number.</i></font>") Else Response.Write("<font color=""red""><i>" & txtPrimeNumber.Text & _ " is <b>not</b> a prime number.</i></font>") End If End Sub Sub PrimeNumberCheck(sender as Object, args as ServerValidateEventArgs) Dim iPrime as Integer = Cint(args.Value), iLoop as Integer, _ iSqrt as Integer = CInt(Math.Sqrt(iPrime)) For iLoop = 2 to iSqrt args.IsValid = True <form method="post" runat="server"> <%-- Create the CustomValidator control --%> <%-- Create two CompareValidator controls: the first ensures that <p><asp:button id="btnSubmit" runat="server" |
相关文章
更多+相同厂商
热门推荐
点击查看更多
点击查看更多
点击查看更多
说两句网友评论