Validator question on positioning

T

tshad

I have about 8 validators on my page and I want to show the error message
next to or below the field that has the error,
but I also want to put 1 message on the top of the page and one on the
bottom of the page that just says something like:

"Errors in some of the fields"

I don't want to put the validators in multiple places and I don't want 8
messages on the bottom if 8 fields have problems.

Is there a way to do this?

Thanks,

Tom
 
B

Brock Allen

You can position the individual validation controls next to the control that
is being validated. Then you can put a ValidationSummary at the both and
the bottom with a HeaderText="Errors in some of the fields". As long as you
don't provide an ErrorMessage property for each of the validation controls,
then the summary will only show the HeaderText.
 
T

tshad

Brock Allen said:
You can position the individual validation controls next to the control
that is being validated. Then you can put a ValidationSummary at the both
and the bottom with a HeaderText="Errors in some of the fields". As long
as you don't provide an ErrorMessage property for each of the validation
controls, then the summary will only show the HeaderText.

That would be perfect.

Also, I tried using it (without leaving the ErrorMessage property out) and
the Header is displayed in Red and the bullets are in Black. Is there a way
to make it all Red?

Thanks,

Tom
 
B

Brock Allen

Also, I tried using it (without leaving the ErrorMessage property out)
and the Header is displayed in Red and the bullets are in Black. Is
there a way to make it all Red?

ForeColor="Red"
 
T

tshad

Brock Allen said:
ForeColor="Red"

I tried that.

I even put the Hex values in. I also put it in both the Validator and the
Summary:

<asp:RequiredFieldValidator ForeColor="#FF0000"
ControlToValidate="SearchName"
Text="<br>You must enter a Search Name"
ErrorMessage="Need a Search Name"
Display="Dynamic"
Font-Size="10px"
runat="server" />
<asp:CustomValidator ForeColor="#FF0000"
ControlToValidate="SearchName"
OnServerValidate="ValidateSearchName"
Font-Size="10px"
Display="Dynamic"
Text="<br>Search Name already exists!"
ErrorMessage="Search Name already Exists"
runat="server" />

<asp:ValidationSummary
HeaderText="Some of the fields are entered improperly or are
missing."
ForeColor="#FF0000"
runat="server"/>

Again, the headertext is red, but the bullet items are black.

Tom
 
J

Juan T. Llibre

I just tried this, and it shows the bullet in red if no character is entered:

<asp:TextBox ID="SearchName" Runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator1"
ForeColor="#ff0000"
ControlToValidate="SearchName"
Text="<br>You must enter a Search Name"
ErrorMessage="Need a Search Name"
Display="Dynamic"
Font-Size="10px"
runat="server" BackColor="#ffffff"
/>

<asp:ValidationSummary ID="ValidationSummary1"
HeaderText="Some of the fields are entered improperly or are missing."
ForeColor="#FF0000"
runat="server"
BackColor="#ffffff"
/>

<asp:Button ID="Button1" Runat="server" Text="Button" />
 
T

tshad

You're right.

What you get from the summary validator is the following:

<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td><font color="Red">Some of the fields are entered improperly or are
missing.
<ul><li>Need a Search Name</li></ul>
</font>
</td>
</tr>
</table>

It looks absolutely correct.

But deep in one of my class files there was an entry:

p,li,ol,ul{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #333333;
text-decoration: none;
line-height: 14px;
}

This overrode the font (#333333 is sort of charcoal grey). If I remove the
style from the css file, it works fine.

I now need to find a way to override this, as I am not actually doing the UL
(asp is) so can't put a class to override the general one directly on the UL
tag.

Thanks,

Tom

I will have to find a way to override this in my
 

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

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top