Asp.net 验证失败,重定向到其他网页
当验证失败超过3次时,用户将转到另一个页面,我如何编码?我将使用CustomValidator执行验证。在CustomValidator的代码中,我将使用ViewState变量跟踪验证失败的次数,如果变量>3,则我将使用Response.Redirect()转到其他页面 下面是一些示例代码:Asp.net 验证失败,重定向到其他网页,asp.net,Asp.net,当验证失败超过3次时,用户将转到另一个页面,我如何编码?我将使用CustomValidator执行验证。在CustomValidator的代码中,我将使用ViewState变量跟踪验证失败的次数,如果变量>3,则我将使用Response.Redirect()转到其他页面 下面是一些示例代码: Property ValidationFailed() As Integer Get If ViewState("ValidationFailed") Is
Property ValidationFailed() As Integer
Get
If ViewState("ValidationFailed") Is Nothing Then
Return 0
Else
Return ViewState("ValidationFailed")
End If
End Get
Set(ByVal value As Integer)
ViewState("ValidationFailed") = value
End Set
End Property
Public Function ValidationCode(ByVal arg As Object) As Boolean
'TODO: Code that does the validation
End Function
Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
args.IsValid = ValidationCode(args.Value)
If Not args.IsValid Then
ValidationFailed = ValidationFailed + 1
End If
If ValidationFailed > 3 Then
Response.Redirect("somepage.aspx")
End If
End Sub