473,403 Members | 2,270 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,403 software developers and data experts.

CustomValidator bug?

Hi.

I am fighting the CustomValidator strange behavior for second day already.
I created some test project which is only to reproduce the problem.

1. I created UserControl which has an only a Custom Validator
2. in UserControl::Page_Load i set
CustomValidator1.IsValid = false;

3. I insert the User Control into the page and have a submit button there.
So when i run the project it shows me errors from CustomValidator (because
IsValid set to false)
But when i click submit button there is no error shown and Page.IsValid
returns true.
Am i missing something? Where should i set CustomValidator1.IsValid = false;
so the Page.IsValid would be set to false as well?
Thanks.
George.
Nov 17 '05 #1
2 6036
Got to the bottom of it.
It turned out that I must provide handler CustomValidator.ServerValidate and
set args.IsValid = false in it.

Otherwise the IsValid is reset to true.

Which is not very good design. I would say if ServerValidate event is not
handled then IsValid must stay as is.

Thanks.
George.
"George Ter-Saakov" <we@hotmail.com> wrote in message
news:ug**************@TK2MSFTNGP10.phx.gbl...
Hi.

I am fighting the CustomValidator strange behavior for second day already.
I created some test project which is only to reproduce the problem.

1. I created UserControl which has an only a Custom Validator
2. in UserControl::Page_Load i set
CustomValidator1.IsValid = false;

3. I insert the User Control into the page and have a submit button there.
So when i run the project it shows me errors from CustomValidator (because
IsValid set to false)
But when i click submit button there is no error shown and Page.IsValid
returns true.
Am i missing something? Where should i set CustomValidator1.IsValid = false; so the Page.IsValid would be set to false as well?
Thanks.
George.

Nov 17 '05 #2

"George Ter-Saakov" <we@hotmail.com> wrote in message
news:ug**************@TK2MSFTNGP10.phx.gbl...
Hi.

I am fighting the CustomValidator strange behavior for second day already.
I created some test project which is only to reproduce the problem.

1. I created UserControl which has an only a Custom Validator
2. in UserControl::Page_Load i set
CustomValidator1.IsValid = false;

3. I insert the User Control into the page and have a submit button there.
So when i run the project it shows me errors from CustomValidator (because
IsValid set to false)
But when i click submit button there is no error shown and Page.IsValid
returns true.
Am i missing something? Where should i set CustomValidator1.IsValid = false; so the Page.IsValid would be set to false as well?
Thanks.
George.


To implement a CustomValidator you need to handle the ServerValidate event.
private void CustomValidator1_ServerValidate(object source,
System.Web.UI.WebControls.ServerValidateEventArgs args)
{
args.IsValid = false;
}
Hans Kesting
Nov 17 '05 #3

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

Similar topics

7
by: jcpmeticulus | last post by:
Hi I've spent the last day or so debugging a problem with a CustomValidator and am now totally stumped! Basically I use a number of CustomValidator's on my page, but have cut this down now to...
1
by: bill yeager | last post by:
I'm using the customvalidator in my web page. I get the following error when I try to run the web page: Unable to find control id 'lstRider' referenced by the 'ControlToValidate' property of...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
3
by: Ronan Dodworth | last post by:
Hi there I'm having a little bit of a problem with my customvalidator control. The problem is the javascript runs fine on my local webserver IIS but not when I post it to the web hosting server....
3
by: philipl | last post by:
hi, i have a textbox in my edititemtemplate in my datagrid. I have created a customvalidator for it, when i update the row the appropiate function gets called to customvalidate but the problem...
1
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
0
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the...
1
by: Beffmans | last post by:
Hi I have defined an customvalidator on my TextBox: function clientvalidate(source, arguments){ { // even number? if (arguments.Value%2 == 0) arguments.IsValid = true; else
1
by: David | last post by:
I need help with CustomValidator in 1.1. I added the CustomValidator control and code as per the doc., (See below) However, the code is never executed. Is there an extra switch or setting to...
2
by: Jeff | last post by:
hey net 3.5 I have problem with a customvalidator. I enter values into the TextBox named "txt" and clicks on the save button (ibSave) then the TestValidate method get triggered. TestValidate...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.