G
Guest
Hello,
I am new to .NET, and a custom validator is giving me a lot of grief.
I want to use a Custom Validation control and for some reasons it's not firing the validation procedure. I am using .NET framework 1.0
Here is the declaration of the control
<asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 103; LEFT: 304px; POSITION: absolute; TOP: 408px" runat="server" ErrorMessage="Bad input -- please correct" EnableClientScript="False" ControlToValidate="TextBox1"></asp:CustomValidator>
I also have a text box and a button on the form. When a user clicks a button, the following code does run:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsValid Then
'do something
End If
End Sub
I expect that when the line "IsValid" is executed, the validator will go into n event handler:
Private Sub CustomValidator1_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
If TextBox1.Text = "" Then
source.isvalid = False
Else
source.isvalid = True
End If
End Sub
….but, for some reasons, this is not happening. The CustomValidator1_ServerValidate is never called. (I know that I could have used the Required Validator for the example as it's presented here, but actually I do need to use the Custom validator because the check condition is going to be much more complex.)
Your help is be greatly appreciated!
Evgueni
I am new to .NET, and a custom validator is giving me a lot of grief.
I want to use a Custom Validation control and for some reasons it's not firing the validation procedure. I am using .NET framework 1.0
Here is the declaration of the control
<asp:CustomValidator id="CustomValidator1" style="Z-INDEX: 103; LEFT: 304px; POSITION: absolute; TOP: 408px" runat="server" ErrorMessage="Bad input -- please correct" EnableClientScript="False" ControlToValidate="TextBox1"></asp:CustomValidator>
I also have a text box and a button on the form. When a user clicks a button, the following code does run:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsValid Then
'do something
End If
End Sub
I expect that when the line "IsValid" is executed, the validator will go into n event handler:
Private Sub CustomValidator1_ServerValidate(ByVal source As System.Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
If TextBox1.Text = "" Then
source.isvalid = False
Else
source.isvalid = True
End If
End Sub
….but, for some reasons, this is not happening. The CustomValidator1_ServerValidate is never called. (I know that I could have used the Required Validator for the example as it's presented here, but actually I do need to use the Custom validator because the check condition is going to be much more complex.)
Your help is be greatly appreciated!
Evgueni