J
Jaime Stuardo
Hi everybody...
I am testing custom validation in a test ASPX page and it isn't working. I
followed a tutorial but when I compiled the code, the field isn't validated.
The tutorial says that I have to add a CustomValidator control, then set the
Text, ErrorMessage and ControlToValidate properties. In order to add a
custom function, I have to double click on the control and add my custom
function. After that, the control validation should work, but it didn't.
This is the ASPX code of the control:
<asp:CustomValidator id="CustomValidator1" runat="server" ErrorMessage="El
número debe ser par" ControlToValidate="TextBox7">Ese no es un número
par</asp:CustomValidator>
And this is the code-behind function:
private void CustomValidator1_ServerValidate(object objFuente,
System.Web.UI.WebControls.ServerValidateEventArgs objArgs)
{
int numero_par = int.Parse(objArgs.Value);
objArgs.IsValid = (numero_par % 2 == 0);
}
When I place a breakpoint in the function, it isn't called either.
What am I missing?
Thanks a lot in advance
Jaime
I am testing custom validation in a test ASPX page and it isn't working. I
followed a tutorial but when I compiled the code, the field isn't validated.
The tutorial says that I have to add a CustomValidator control, then set the
Text, ErrorMessage and ControlToValidate properties. In order to add a
custom function, I have to double click on the control and add my custom
function. After that, the control validation should work, but it didn't.
This is the ASPX code of the control:
<asp:CustomValidator id="CustomValidator1" runat="server" ErrorMessage="El
número debe ser par" ControlToValidate="TextBox7">Ese no es un número
par</asp:CustomValidator>
And this is the code-behind function:
private void CustomValidator1_ServerValidate(object objFuente,
System.Web.UI.WebControls.ServerValidateEventArgs objArgs)
{
int numero_par = int.Parse(objArgs.Value);
objArgs.IsValid = (numero_par % 2 == 0);
}
When I place a breakpoint in the function, it isn't called either.
What am I missing?
Thanks a lot in advance
Jaime