Validator messages

T

tshad

I have a page that is very long so I have set it up to page using <div> to
display or hide the different pages. When I get to the last page the user
submits the page.

This works great, except that if one of the validators finds an error and it
isn't on the last page, the user won't see it. What I want to do is know
that there is an error on the 2nd page and make that page visible (which
would show the validator error message) and the user can make his changes.

Is there a way to know that a validator has fired and which one fired?

Thanks,

Tom
 
T

tshad

tshad said:
I have a page that is very long so I have set it up to page using <div> to
display or hide the different pages. When I get to the last page the user
submits the page.

This works great, except that if one of the validators finds an error and
it isn't on the last page, the user won't see it. What I want to do is
know that there is an error on the 2nd page and make that page visible
(which would show the validator error message) and the user can make his
changes.

Is there a way to know that a validator has fired and which one fired?

I figured what I would do is to check all the validators and see if they
passed. Knowing what page the validator is on would allow me to make
visible the page that had the error.

The problem is that the "IsValid" doesn't seem to get set for the particular
validator, but the Page.IsValid does.

For example:

I have the following texbox and validator:

<asp:textbox id="ProfileName" columns="45" runat="server" />
<asp:RequiredFieldValidator
id="NameValidator"
ControlToValidate="ProfileName"
Display="Dynamic"
Text="Passport Name Required"
runat="server" />

I know that this validator is finding an error and setting the text to
display. It also sets the Page.IsValid correctly.

But when I run the following routine in the event that my submit button
calls, I get the NameValidator.IsValid showing as true and the Page.IsValid
showing as false.

Function CheckErrors() as Boolean
If NameValidator.IsValid then
trace.warn("NameValidator is true")
else
trace.warn("NameValidtor is false")
end if

if (Page.IsValid) then
trace.warn("Page Validator is true")
else
trace.warn("Page Validtor is false")
end if
end Function

Why is this?

Thanks,

Tom
 
A

Aaron Corcoran

Tom,

I might be misunderstanding you, so I will apologize in advance if
reading this post has wasted precious moments that you will be unable
to recover =). From my understanding, you have a very long page that
is separated by <div> tags. My first suggestion would be to make these
panel controls. You can perform the same functionality by making the
panels visible and invisible.

The benefit that you will get from this is that you will be able to put
separate validation summary controls in EACH panel. Thus if a user is
going through a wizard type application, they will not be able to
continue to the next "page" (panel), until all validators in that
panel are valid.

Does that make sense? Each page (panel), would contain the user input
fields, validators for the necessary fields, and a validation summary.
Once a user clicks the next button to move to the next page (panel),
the validation would trigger. If it is valid, the next page is
displayed...rinse and repeat.

I hope this helps!
Aaron
 
T

tshad

Aaron Corcoran said:
Tom,

I might be misunderstanding you, so I will apologize in advance if
reading this post has wasted precious moments that you will be unable
to recover =). From my understanding, you have a very long page that
is separated by <div> tags. My first suggestion would be to make these
panel controls. You can perform the same functionality by making the
panels visible and invisible.

Why would that be better than <div id="page1" visible="false"
runat="server">?

I was looking at some articles on the Web about using Panels, just as you
suggest, to break apart large pages into byte size pieces. They do the same
thing I do to display pages by setting the panel/div visible attribute to
true or false.
The benefit that you will get from this is that you will be able to put
separate validation summary controls in EACH panel. Thus if a user is
going through a wizard type application, they will not be able to
continue to the next "page" (panel), until all validators in that
panel are valid.

Do the validators work differently in Panels then Divs?
Does that make sense? Each page (panel), would contain the user input
fields, validators for the necessary fields, and a validation summary.
Once a user clicks the next button to move to the next page (panel),
the validation would trigger. If it is valid, the next page is
displayed...rinse and repeat.

Also, what about the Validators IsValid not showing as false when it fails
validation?

Thanks,

Tom
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top