日期:2014-05-20  浏览次数:20480 次

求CustomValidator控件的后台事件响应代码
如何写CustomValidator控件的后台事件响应代码?

------解决方案--------------------
你参考这个
<Html>
<Form Id= "Form1 " Runat= "Server ">
请输入10 的倍数: <ASP:TextBox Id= "txtValue " Runat= "Server "/>
<ASP:Button Id= "btnOK " Text= "确定 " OnClick= "btnOK_Click "
Runat= "Server "/> <br>
<ASP:CustomValidator Id= "Validor1 " Runat= "Server "
ControlToValidate= "txtValue "
OnServerValidate= "CustVali "
Text= "必需输入十的倍数! "/> <br>
<ASP:Label Id= "lblMsg " Runat= "Server "/>
</Form>

<Script Language= "VB " Runat= "Server ">
Function CustVali(Sender As Object, Value As String)As Boolean
If Value.ToInt16 Mod 10=0 Then
Return True
Else
Return False
End If
End Function
Sub btnOK_Click(Sender As Object,e As Eventargs)
If Page.IsValid Then
lblMsg.Text= "验证成功! "
Else
lblMsg.Text= "验证失败! "
End If
End Sub
</Script>
</Html>