validationsummary question

J

john.livermore

I am successfully using the client side validation controls, but there
are a couple aspects of their behavior that I wish to modify. I cannot
see how to accomplish this through the properties, but I thought I
would ask here for advice.

- ValidationSummary

When there are validation errors on the page, the summary control
displays its HeaderText at the top of my form. However, it lists each
validation problem. Additionally each error is shown next to the
problem control. This is all fine except for the summary control
listing each validation problem. How can I make it so that the summary
control only displays its HeaderText and suppresses the errors for each
control?

- Multiple Validators For a Control

I have a required field and a regular expression validator on one
control. The controls are created on the form in the order of required
validator first and reg exp validator second. When the control has
some data, but fails the regular expression, the error message is
shifted to the right of the required field message (which remains
hidden). Looking at the HTML I see the validators use a
visibility=hidden style instead of a display=none style. Is there a
way to make the validators use the latter attribute? This would solve
the alignment issue.

Thanks,
John
 
B

Brock Allen

The ValidationSummary is controlled by what you specify for the ErrorMessage
property for each of the individual Validation controls. If you leave this
empty then the ValidationSummary won't show an entry for that validation
control. If you were previously using the ErrorMessage property to indicate
the message next to the control you were validating, use the Text propery
instead (or just put content inside the validation control begin & end tags).
 
B

Brock Allen

Oops, I dind't answer the second half of your question. You want to use the
Display="Dynamic" (instead of Display="Static") on the validation controls.
This will render visibility:hidden instead of display:none.
 
J

john.livermore

Great, thanks for the tips. Another question if you don't mind.

I notice the validation puts the following code in the onsubmit event
for the form...

if (!ValidatorOnSubmit()) return false;

However, on another site I have it only puts...

ValidatorOnSubmit();

On the former, I cannot get the form to submit and the latter works
fine. Also the latter is what I see on other asp.net sites. What
would cause the validation framework to put the former code in?

Thanks,
John
 
P

Peter Blum

Hi John,

The ValidationSummary is not designed to only show the HeaderText. You have
to add a minimum of something like " " to the ErrorMessage property and
set its DisplayMode to SingleParagraph. You will always get an extra line
containing those spaces.

I wrote a replacement to Microsoft's validators that greatly increases the
featureset of the validation system. "Professional Validation And More"
(http://www.peterblum.com/vam/home.aspx) basically addresses most complaints
users have with Microsoft's validators, avoiding the custom code and hacks
users have faced. Some examples of how it works better for you:
- The ValidationSummary's DisplayMode has a setting of "None" so that you
never show anything for error messages in the summary.
- The RegexValidator has a property, IgnoreBlankText, that when false, will
report an error if the text is blank. That avoids adding a
RequiredFieldValidator.
- When you want to combine validators together under one error message, use
my MultiConditionValidator.
- All of my 22 validators support client-side validation on IE, IE/Mac,
Mozilla, Netscape 7, FireFox, Opera 7, and Safari. Microsoft's only works on
DHTML browsers (IE and IE/Mac).

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx
 
B

Brock Allen

Hmm, don't know iff the top of my head withouyt looking at all of the code.
Perhaps it's a diff between ASP.NET 1.0 and 1.1?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top