开发者

Custom validator is not firing even the textbox is not empty

开发者 https://www.devze.com 2023-03-09 17:52 出处:网络
I have a cutomvalidator, textbox.text = 1 and a subroutine: 1. asp:TextBox id=\"tbxNumber\" runat=\"server\" MaxLength=\"100

I have a cutomvalidator, textbox.text = 1 and a subroutine:

1.
asp:TextBox id="tbxNumber" runat="server" MaxLength="100

2.
asp:CustomValidator id="vNumeric" runat="server" ControlToValidate="tbxNumber" Display="None" OnServerValidate="ValidateNumbers2"

3.
Sub ValidateNumbers2(ByVal source As Object, 开发者_运维百科ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)

If Not IsNumeric(args.Value) Then  

  args.IsValid = False

Else

   args.IsValid = True

End If


End Sub

When I try to debug vNumeric.Validate, sub ValidateNumbers2 won't fire? Why?

Ideas? I'm wasting my too much time on this little problem. I only have to use customvalidator for some reasons.


if the textbox is empty while you're testing, it will not fire. you need to set

 ValidateEmptyText="True"

in your customvalidator.


Have you changed ClientId mode of it, Validators might not supports client Id mode static

Validators and ClientIDMode issue (ASP.NET)

////////////////////

You may try using Force Validation by Page.Validate();

0

精彩评论

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