Solved

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

Posted on 2007-11-18
2
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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