473,394 Members | 1,709 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Problem with custom validation

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
Nov 19 '05 #1
3 1350
"Jaime Stuardo" <js******@manquehue.net> wrote in news:u$r#W#ewFHA.3252
@TK2MSFTNGP10.phx.gbl:
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.


You didn't assign the event handler...
private void CustomValidator1_ServerValidate(object objFuente,
System.Web.UI.WebControls.ServerValidateEventArgs objArgs) handles
myCustomerValidator.servervalidate
Also... you may or may not want to assign ControlToValidate. I believe when
you have ControlToValidate set, it won't validate if the entry is blank.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #2
but handles keyword is only for VB.NET... I'm using C#

"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1...
"Jaime Stuardo" <js******@manquehue.net> wrote in news:u$r#W#ewFHA.3252
@TK2MSFTNGP10.phx.gbl:
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.


You didn't assign the event handler...
private void CustomValidator1_ServerValidate(object objFuente,
System.Web.UI.WebControls.ServerValidateEventArgs objArgs) handles
myCustomerValidator.servervalidate
Also... you may or may not want to assign ControlToValidate. I believe
when
you have ControlToValidate set, it won't validate if the entry is blank.
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com

Nov 19 '05 #3
"Jaime Stuardo" <js******@manquehue.net> wrote in news:#dcHXNjwFHA.904
@tk2msftngp13.phx.gbl:
but handles keyword is only for VB.NET... I'm using C#


haha... oops, didn't notice u were using C# :S
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ninja_kornjaca | last post by:
Hello, I'm having a pretty strange problem and I'd appreciate if anyone could help me with it. I'm having a custom error page on my IIS. Specifically, I've written my own ASP (classic ASP)...
2
by: Barbara Alderton | last post by:
I setup some standard Required Field Validation controls and one Custom validation control on an ASP.NET page (within a user control) to validate text entry. I also setup a Summary Control to post...
3
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario: i have many webforms in a site, most with two...
2
by: SimonH | last post by:
Hi All, I'm having problems getting a custom validator to work. I'm hoping someone could perhaps notice what I've missed. I only want to provide a server side validation method. The problem is...
0
by: A.J. van der Burg | last post by:
Hi all, I have a serious problem with asp.net validation: I developed a custom validation summary control, which will lookup error messages from an external source based on the...
0
by: Marek | last post by:
Hi all, I have custrom control with four elements: text box, regular expression validator, required field validator and custom validator. Next this control is dragged on to web site with several...
3
by: Andy | last post by:
Hi folks, I have a customvalidator control that works properly if it isn't contained in an ASP:TABLE. But, when I place it inside an ASP:TABLE, I find that _ServerValidate doesn't get fired,...
4
by: kpg | last post by:
I can't get the CustomValidator (CV) ErrorMessage to display in the ValidationSummary. On the same page I have several RequiredField Validators and a Range Validator, that all work just fine,...
1
by: asharda | last post by:
I have a custom property grid. I am using custom property grid as I do not want the error messages that the propertygrid shows when abphabets are entered in interger fields. The custom property...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.