Page.Validate() not validating custom validators


when i call Page.Validate("myGroup") 

The custom validators in the validation group myGroup  are not validated, i.e.  validator.IsValid returns true even if the validator failed on  page submit.

 code snippet:

            foreach (IValidator validator in this.Validators)
                if (!validator.IsValid)

                      //take action on validation failure

  the code works fine except if validator is of type custom validator

any hepl is appreciated .


Home Is Where the Wind Blows
10/23/2006 8:00:06 AM 93655 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 6

You are testing the IsValid property on each validator after validating. That is good. Another way to do that is test Page.IsValid = true (just once after validating). But this is not the solution in your case.

Here are the possibilities:

1. You did not setup the ServerValidate event on the customvalidators. That event handles your custom validation.

2. The Validation Group name on the validators is not "ToolsImplementation".

3. The CustomValidators are Enabled=false or Visible=false. Note that if they are contained in another control that is Visible=false, they will be Visible=false too.

--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
10/23/2006 10:51:53 PM

Hi PLBlum,

Thanks for the reply. Actually all my custom validators are having a their ClientValidationFunction set to a javascript function to carry out the validation and the respective control value is validated as soon as page is submitted be a button in having the same validation group as that of the validator.

Do I need to set up the ServerValidate event in this case? 

Home Is Where the Wind Blows
10/24/2006 5:30:44 AM
You most definately do, otherwise users with javascript disabled would go straight through :)
10/24/2006 5:40:01 AM

Ok that's right. I think it solves my problem.

Thanks all. 

Home Is Where the Wind Blows
10/24/2006 1:57:54 PM

Similar Artilces:

Validators not Validating
Would anyone know why the validations on the page below wouldn't work. I am going through a book and learning and for some reason when I put in the last subroutine to insert the record the validation checks on the controls on the form no longer work.<%@ Import Namespace="System.Data.SqlClient" %><html><head><title>The Intranet Site</title><script runat="server" language="VB">Dim objConn As New SQLConnection("Server=XXXXXXX; database=Dorknozzle; uid=XXXXXXX; Pwd=XXXXXXXX;")Dim objCmd As SQLCommandDim objRdr As SQLDataReader  Sub...

To validate or not to validate
Hey people! Here is my situation - I've created a dynamic data website with one table. The fields of this table are mostly varchar() not NULL, and all fields are defined with default value. When trying to insert new row with empty values I get required validation on all fields. What would be the best way to enable this validation only on some of these fields, while using default values for the others? For example empty string for varchar or 0 for int, etc Thanks Michael no in this case it will be add what error its return when u add. .Net DeveloperWeb Site Design and W...

Validator.Validate() ?
Hello guys,When I created a function to do custom validation I tried to use RegularExpressionValidator.Validate(). My code: 1 protected void EvaluateNewGateWay(object source, ServerValidateEventArgs args) 2 { 3 if (chBoxNewGW.Checked) 4 { 5 RegularExpressionValidator rev = new RegularExpressionValidator(); 6 rev.ErrorMessage = "REV Error"; 7 rev.ControlToValidate = "txtNewGW"; 8 rev.ValidationExpression = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?"; 9 rev.Tex...

Web form and a gridview on the same page with data validators
I have a form where a user can submit a new customer and directly below that is a gridview where they can view the customer they just submited plus their other customers they have submited in the past. Now this gridview has the edit/update property so the user can modify their customer information. The whole idea is to have 1 single page where a user can do everything they need to without having to be linked to another page. On this page we can submit new customer info and view the status/info of existing customers and edit that info as needed. So far that works fine. I can submit the new c...

Custom Validator not validating
Hi Everyone,Im fairly new to and am trying to create a custom validator. In the code I have posted I have created a custom validator for a DDL which makes a text box enabled if a setup file is selected from the DDL (among other options). The purpose of this text box is to provide a setup file path to include in some release info I am creating for an application. I have then created a custom validator to make sure a path has been included in the text box if it is enabled. The problem I am having is that for some reason my custom validator for my text field where the file path should b...

i write the password requirment validation in custom validator. but custom validator not fired
i tried in custom validator for password requirement. but it is not fired . wat i did the mistake tell me.i enterd in pwd text box bellow 5 it is showing error and enter the correct and showing error. i think it is not fired <script language="javascript" type="text/javascript">function validate(source,argument) {var data=argument.Value.split(''); //start bysetting falseargument.IsValid=false; //checklengthif(data.length < 5 || data.length > 15) return;argument.IsValid=true; elseargument.IsValid=false; }   </script> <...

Custom Validator not firing on Page.Validate
Note that I am using ASP.NET 1.x I have a custom validator that is server side only. When the user hits the save button, I check the status if a checkbox. If this checkbox is checked, then I turn the custom validator on (I also turn a lot of other validators on/off here). I know the custom validator is enabled as I check it through the debugger. But when I call Page.Validate(), the code for the custom validator is never run. The function for the custom validator has 'handles cusval.servervalidate' on it and the html also has 'onServerValidate=function'. I am now s...

.net validation vs custom validation
Hello, Coming from a background of Classic ASP. I have a logic of validation which also does out security and account. Basically, we use a stored proceedure to validate and then also log success, failures, attempts etc Can this be done using .net validation or i have to build my own validation logic ? And how is this done ? thanks Ehi You can use Custom validator control Using the CustomValidator Control  Hosam Kamel Remember to click on Mark as answer on the post that helped you...

forcing validation for all validators having different validation groups on a page
Hi friends,I have a page with two sections, say section A and section B with each section having its own submit button. I have assigned seperate validation groups for submit button and validators in each section. so partial validation on submit of each section is occuring perfectly. Now i've got a third submit button to submit whole page and i want all the validations to take place on click of this button before submitting the page, which is not taking place because of the validation groups i have assigned. can anybody help me with this.Thankspushpendra Home Is Where the Win...

Custom validator in Validation summary
Hi. I have 2 textboxes on my page. Both of them got 2 validators. One required field and one custom validator. I also got a validation summary..The validation works perfect, but only the two required field validators show in the summary, and not the custom....Is it possible to show the custom aswell? Do you have the error message defined for the custom validator?  Hi!The RequiredFieldValidator controls generate client script and therefore they do not require a postback. The CustomValidator that you've created only has the server side code associated with it and therefore r...

Validation Summary and Custom Validators
I am trying to show a message box whenever an error occurs. The validation summary I have on my page works (i.e. message box is displayed) with the required field validators but not with the custom validators. My question is can the validation summary show a message box for custom validation errors? If so, what are the settings that I need? The ValidationSummary only provides client-side output (messagebox or updates to the control itself) when there is client-side code for the validator. If your customValidator does not have any client-side code, it cannot contribute to the valid...

how to validate the radiobuttonlist by custom validator
i need to validate the radiobuttonlist that only the right option should be serlected , how should i write a custom validation control for radiobuttonlist Thanks & Regards Neeluneelu gupta Its not an easy task to write the client-side code but the server side code only requires that you look at the Items collection for the ListItem you want and check its Selected property: Dim vLI As ListItem = RadioButtonList1.Items[2]   ' get the 3rd item args.IsValid = vLI.Selected FYI: I have built a replacement to Microsoft's validators that includes a validator that can handle ...

Validation Summary and Custom Validator
hello all, I am trying to get the Validation Summary message box to work on my page. If I use Field Validators it works fine, but if I use a custom validator it does not. I can still get the on page list to appear via the Summary, so I know it's at least getting the errors off of the page. However it will not load the message box when I use a custom validator. Is there some trick to getting this to work beyond the other validators?   The message box will only be displayed when validation fails on the client-side. If you haven't set the ClientValidationFunction property to th...

custom validator to validate an integer
hello guys...I have a dropdownlist and a search txtbox , if id was selected from the dropdownlist , the searchtxt must be a number , I added a custom validator and here is it's functionprotected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) {if (TypeDropList.SelectedValue == "Id") {bool checker; checker = IdCheck(SearchTXT.Text);if (checker) args.IsValid = true; elseargs.IsValid = false; } }private static bool IdCheck(string idtext) {int idnumber = 0; if ( !int.TryParse(idtext , out idnumber))return false; elsereturn true; ...

Web resources about - Page.Validate() not validating custom validators -

Talking to police about Ghomeshi allegations was validating: Decoutere
One of the women accusing former CBC host Jian Ghomeshi of violent behaviour is encouraging other potential victims not to be afraid of speaking ...

Validating Input and Interprocess Communication
Describes techniques to use and factors to consider to make your code more secure from attack.

Validating team-by-team R and RBI predictions for 2012 NL Edition
As I've explained in the first of these articles , I made a few predictions over at dear, departed fantasy blog RotoHardball during the last ...

"It is important not to create a precedent validating the prohibition of the sale of any object of a ...
"... regardless of the culture concerned... Our goal has always been to showcase Hopi culture and make it accessible to the largest number of ...

Validating the Donald
Validating the Donald by digby In Salon today , I wrote about the right wing media's immigration backlash strategy by validating Donald Trump's ...

Validating your marketing audience
... enjoyed this, please share it with your network! Want to read more like this from Christopher Penn ? Get daily updates now: The post Validating ...

Validating Albert Einstein, physicists make major discovery about the early universe
In the beginning there was the Big Bang. What we know about this time is that the universe was extremely hot, dense and almost uniform; it was ...

Validating Architecture through LINQ Query
... is simple enough to get validated at a glance. But at a glance is not enough. What about defining custom rules that take care of validating ...

From Data to Action – Best Practices for Validating and Optimizing Your Digital Campaigns - comScore ...
In this webinar, comScore Senior Industry Analyst Jason Patterson explores how you can use comScore's validated data to optimize and improve ...

TDD of a WinForm app – Part 5 – Validating the account data
In our last post, we worked on allowing our user to enter new accounts – basically making our AddAccountForm usable. We were able to do that ...

Resources last updated: 12/9/2015 3:22:52 AM