Page validation with multiple panels

J

Jonas

Hi!

I have aspx-page where I use multiple panels to make room for more controls
than would otherwise fit onto one page. On submit, the controls on all
panels, visible or not, should be validated with the ASP.NET validators, and
if the page is valid, it is sent to the database in one transaction. But it
seems that only the controls on the visible panels gets validated.

Is there a easy way to solve this problem?

Brgds

Jonas
 
J

Jonas

I now got it to work if I in the serverside code for the submit button set
my panels to be visible and then call Page.Validate. This sets Page.IsValid
to false and I can check for this. But I want to messagebox from the
ValidationSummary control to show up as usual, how can I trigger this
without having to loop through the Page.Validators collection manually?

Brgds

Jonas
 
M

MWells

Jonas, most .NET controls actually don't render HTML at all when they're
marked as Visible=false. Without HTML, there's no way for a client-side
validator to work.

Two immediate possibilities I can think of;

1. Do server-side validation. With viewstate, the contents of a hidden
control should be preserved across hide/show operations, and the data should
be available in the server postback. If that's correct, you should be able
to validate all of your controls server-side. This necessitates a postback,
but solves your immediate issue.

2. Create/find a new panel type that renders its contents, but perhaps
encases them in a hidden DIV. I've never tried this, and not all browsers
will respect a CSS hidden tag, but it may be a resonable approach. As long
as the controls actually exist in your page, the validator js should
function. Note that your validators themselves will have to be outside of
the hidden panels in order for the user to see the validation error text.

/// M
 
J

Jonas

Hi!

I've tried the second approach by replacing my asp:panels with div-tags. I
got one div as a container and the two inner div's that I set
visibility=hidden and left=1000px when I want that particul div to be
replaced by the other. It seems to work ...

/Jonas
 

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,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top