467,923 Members | 1,242 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,923 developers. It's quick & easy.

Displaying a message contigent on another validator.

I'm using some validators for a form. If the field is invalid, the page
reloads with the error next to the field.

This works, and I like it.

I'd also like to add a separate message to the top of the page along the
lines "there appears to be an error with your submission. Please check the
form below. Items to correct appear in RED".

What would be the best way to do this? I was thinking that I could just wrap
it in a panel and set it to visible/hidden based on the validators. Is there
a way to check for ANY validator error? Something like:

if any validator = error, then panel.visibility = true

-Darrel
Nov 18 '05 #1
  • viewed: 1043
Share:
5 Replies
look at the Validation Summary control

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm using some validators for a form. If the field is invalid, the page
reloads with the error next to the field.

This works, and I like it.

I'd also like to add a separate message to the top of the page along the
lines "there appears to be an error with your submission. Please check the
form below. Items to correct appear in RED".

What would be the best way to do this? I was thinking that I could just wrap it in a panel and set it to visible/hidden based on the validators. Is there a way to check for ANY validator error? Something like:

if any validator = error, then panel.visibility = true

-Darrel

Nov 18 '05 #2
Try ValidationSummary.
I believe this is designed exactly for this purpose.
(Only been coding .NET for 1 week now though)
:-)

AJ
"darrel" <no*****@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
I'm using some validators for a form. If the field is invalid, the page
reloads with the error next to the field.

This works, and I like it.

I'd also like to add a separate message to the top of the page along the
lines "there appears to be an error with your submission. Please check the
form below. Items to correct appear in RED".

What would be the best way to do this? I was thinking that I could just wrap it in a panel and set it to visible/hidden based on the validators. Is there a way to check for ANY validator error? Something like:

if any validator = error, then panel.visibility = true

-Darrel

Nov 18 '05 #3
> look at the Validation Summary control

Curt/Andrew:

THANKS!

Unfortunately, once again, this seems to be a control that doesn't QUITE
give me the flexibility I need.

I want to have a custom error at the top, with the specific errors showing
up at each field (with their own validator controls). I can add custom text
in the validationSummary using the HeaderText attribute. However, it insists
on also showing the errorSummaries. I can turn off the errorSummaries, but
that also turns off the HeaderText.

So not *quite* what I was working for.

Any other suggestions?

-Darrel
Nov 18 '05 #4
Let's try a different approach.

Add a label to the page that has the desired text.
When IsPostBack=false, set its Visible property to false
When IsPostBack=true, set its Visible property according to the Page.IsValid
property. Do this after Page.Validate() has run (usually your post back
event handler).

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"darrel" <no*****@hotmail.com> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
look at the Validation Summary control
Curt/Andrew:

THANKS!

Unfortunately, once again, this seems to be a control that doesn't QUITE
give me the flexibility I need.

I want to have a custom error at the top, with the specific errors showing
up at each field (with their own validator controls). I can add custom

text in the validationSummary using the HeaderText attribute. However, it insists on also showing the errorSummaries. I can turn off the errorSummaries, but
that also turns off the HeaderText.

So not *quite* what I was working for.

Any other suggestions?

-Darrel

Nov 18 '05 #5
Here is one I'm using:

<asp:customvalidator id=CustomValidator2 style="Z-INDEX: 111; POSITION:
relative;
TOP: 20px" runat="server"
ErrorMessage="New Password Must Contain Both Letters and Numbers"
EnableClientScript="False"
OnServerValidate="checkNewPass">*</asp:customvalidator>

Notice the * between the tags. This text will appear wherever you place
this validator on your page.
The Error Message only goes to the summary.

AJ

"darrel" <no*****@hotmail.com> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
look at the Validation Summary control
Curt/Andrew:

THANKS!

Unfortunately, once again, this seems to be a control that doesn't QUITE
give me the flexibility I need.

I want to have a custom error at the top, with the specific errors showing
up at each field (with their own validator controls). I can add custom

text in the validationSummary using the HeaderText attribute. However, it insists on also showing the errorSummaries. I can turn off the errorSummaries, but
that also turns off the HeaderText.

So not *quite* what I was working for.

Any other suggestions?

-Darrel

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Abdul Azeem | last post: by
5 posts views Thread by Paul Johnson | last post: by
2 posts views Thread by Bidarkota | last post: by
1 post views Thread by Jeff Williams | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.