Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 160
  • Last Modified:

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

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
megnin
Asked:
megnin
1 Solution
 
SQL_SERVER_DBACommented:
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
 
megninAuthor Commented:
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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now