Multiview and Validation

C

Chuck P

I am using a Multiview control and some validators.
The multiview is being used in a homegrown tab control
Click on a tab it display one of the views.

I have a submit button that I would like to validate all of the
controls in all of the views within the multivew.

I am guessing their is no way this going to happen on the client,
since the controls on the non-displayed views are not available to the
DOM/javascript?

However, on page postback if I do page.validate, page.isValid. I
don't believe the controls in the other views are being tested. How
can I validate all the controls within the multiview?
 
W

Walter Wang [MSFT]

Hi Chuck,

It's a design decision that controls/validators in a hidden View will not
be validated; also you're right about the client-side validation: the
controls inside hidden View aren't rendered to client at all, thus not
possible to validate them at client-side.

As a workaround, I'm afraid you will have to manually make each View active
then do the validation again:

private void ValidateMultiView(MultiView mv)
{
int savedIndex = mv.ActiveViewIndex;
for (int i = 0; i < mv.Views.Count; i++)
{
mv.ActiveViewIndex = i;
Page.Validate();
}
mv.ActiveViewIndex = savedIndex;
}


Note: if you have code in the MultiView's event ActiveViewChanged, please
be aware that above code will trigger the event too; you might want to use
a member variable to bypass the logic there if it's caused by this function.

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top