Solved

How to toggle on/off all validation controls on a web form for testing

Posted on 2007-11-18
2
153 Views
Last Modified: 2013-11-26
I've got a bunch of web forms done with Visual Studio 2005 that have or will have validaiton on each field; mostly RequiredFieldValidators, but others as well.

I want to be able to throw a button on the form temporarily so I can disable all the validation controls for testing purposes.  I sometimes need to test what happens after "Submit" and don't want to have to fill out 165 questions on a form just to see if the next step works.

It's probably not hard to "For each validationControl on this page set Enabled=False" but I'm a beginner and I couldn't find any code to do this.

Thanks.
0
Comment
Question by:megnin
2 Comments
 
LVL 16

Accepted Solution

by:
SQL_SERVER_DBA earned 500 total points
ID: 20309518
I got this from http://www.freevbcode.com/ShowCode.asp?ID=1219...just replace the frame parts with validation ctrl
Sub EnableDisableFrameControls()

    Dim ctl As Control

    For i = 0 To Controls.Count - 1

        Set ctl = Controls(i)

        If TypeOf ctl Is Frame Then

            For j = 0 To Controls.Count - 1

                If TypeOf Controls(j) Is Frame Then

                    If Controls(j).Container Is ctl Then

                        Controls(j).Enabled = ctl.Enabled

                    End If

                End If

            Next j

            For j = 0 To Controls.Count - 1

                On Error Resume Next

                If Controls(j).Container Is ctl Then

                    Controls(j).Enabled = ctl.Enabled

                End If

            Next j

        End If

    Next i

End Sub

Open in new window

0
 
LVL 1

Author Comment

by:megnin
ID: 20314652
Thank you!

Perhaps you could also help me with a question concerning SQL Server 2000 and an Excel external data connection?
Here is the question:  http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/Q_22971008.html

I increased the points here as well.

David
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now