I am using a FormView control to collect, through three TextBox controls, some information to be inserted into a Database Table.
After configuring layout and style of the InsertTemplate and set the FormView Default Mode to Insert, I have associated to each TextBox a RequiredField Validator and a Custom Validator, this latter to check the max number of characters entered in each of the boxes.
While the RequiredField Validation works correctly, the Custom Validator keeps silent.
I have tried to associate a Custom Validator to a TextBox Control outside of the FormView and it works perfectly.
I have noticed that in the two cases there is a difference in the code of the server-based event handler for the control's ServerValidate event.
In the case of the isolated TextBox the code is:
Protected
Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
If args.Value.Length <= 5 Then
args.IsValid =
True
Else :args.IsValid = False
End If
End Sub
In the case of each of the TextBox Controls embedded in the FormView InsertTemplate the code is the same with the exception that the "Handles CustomValidator1.ServerValidate" is missing. Adding it is not accepted. The EventHandler for this CustomValidator Controls has been generated automatically by double clicking on the CustomValidator box.
I need a smart mind looking at this problem to let me go out of this blocking situation.
Lot of thanks are being sent in advance.
Federico