开发者

Custom server side validation in ASP.NET + VB.NET

开发者 https://www.devze.com 2023-01-05 07:12 出处:网络
This has not happened to me before, but for some reason server side validation events are not being triggered:

This has not happened to me before, but for some reason server side validation events are not being triggered: I'm using Code below

<asp:CustomValidator runat="server" id="RefId" OnServerValidate="Ref_Id" ControlToValidate="txtRefId" ErrorMessage="Referral ID is Required." ></asp:CustomValidator>

When I fix the debugger on below code that time the code will not be triggered. plz check below code also.

Protected Sub Ref_Id(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)
    Dim isPresent As String
    isPresent = MembershipManager.IsReferalApproved(Me.txtRefId.Text)
    If isPresent <> "" Then
        addReferralName()
        args.IsValid = True
    Else
        lblRefNotValid.Text = "Referral IDNO does not exist."
        lblRefNotValid.Visible = True
        Me.txtRefName.Text = ""
        args.IsValid = 开发者_如何学编程False
    End If
End Sub


your custom validator's control should have the property ValidateEmptyText = True or the validation won't trigger on an empty textbox


Does your txtRefId Autopostback and CausesValidation?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号