473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Disabling validation in an user control.

Is there a specific method to disable field validators in a user
control.from within a parent page or does it require an ad hoc
approach? The page attribute ValidateRequest does not seem to be
available in user controls. TIA for any inputs.
Jan 30 '08 #1
2 2169
ValidateRequest has nothing to do with validation controls. it enables
validation of postdata to be free of dangerours data (script), only load
postdata to enabled control, and in the case of dropdowns only load postbata
that is in the list.

validation controls can be disabled by setting Enabled=false. you can
recurse the control collection and disable validators:

ControlWalker(myUserControl, delegate(Control ctl)
{
if (ctl is BaseValidator) ctl.Enabled = false;
}

// recurse control collection
public delegate bool ControlWalkerMatcher (Control ctl);
public Control[] ControlWalker(Control ctl, ControlWalkerMatcher matcher)
{
ArrayList list = new ArrayList();
if (matcher(ctl)) list.Add(ctl);
for (int i=0; i < ctl.Controls.Count; ++i)
{
Control[] childList = ControlWalker(ctl.Controls[i],matcher);
if (childList.Length 0) list.AddRange(childList);
}
return (Control[]) list.ToArray(typeof(Control));
}

-- bruce (sqlwork.com)
"ms******@gmail.com" wrote:
Is there a specific method to disable field validators in a user
control.from within a parent page or does it require an ad hoc
approach? The page attribute ValidateRequest does not seem to be
available in user controls. TIA for any inputs.
Jan 30 '08 #2
On Jan 30, 11:41*am, bruce barker
<brucebar...@discussions.microsoft.comwrote:
ValidateRequest has nothing to do with validation controls. it enables
validation of postdata to be free of dangerours data (script), only load
postdata to enabled control, and in the case of dropdowns only load postbata
that is in the list.

validation controls can be disabled by setting Enabled=false. you can
recurse the control collection and *disable validators:

* * ControlWalker(myUserControl, delegate(Control ctl)
* * {
* * * * *if (ctl is BaseValidator) ctl.Enabled = false;
* * }

* * // recurse control collection
* * public delegate bool ControlWalkerMatcher (Control ctl);
* * public Control[] ControlWalker(Control ctl, ControlWalkerMatcher matcher)
* * {
* * * * ArrayList list = new ArrayList();
* * * * if (matcher(ctl)) list.Add(ctl);
* * * * for (int i=0; i < ctl.Controls.Count; ++i)
* * * * {
* * * * * * Control[] childList = ControlWalker(ctl.Controls[i],matcher);
* * * * * * if (childList.Length 0) list.AddRange(childList);
* * * * }
* * * * return (Control[]) list.ToArray(typeof(Control));
* * }

-- bruce (sqlwork.com)

"msch....@gmail.com" wrote:
Is there a specific method to disable field validators in a user
control.from within a parent page or does it require an ad hoc
approach? The page attribute ValidateRequest does not seem to be
available in user controls. TIA for any inputs.- Hide quoted text -

- Show quoted text -
I've seen this code snippet of yours a couple of times. Could you say
something about the purpose of the delegate there? Thanks. I've
written methods that recursively find controls without a delegate.
Jan 30 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: buran | last post by:
Dear ASP.NET Programmers, I have a web user control (a search menu) which has 2 validation controls (one for input and another for the search criterion). I am including this search user control...
2
by: Andy Fish | last post by:
Hi, I have one textbox on the form that needs to have ValidateRequest disabled, but it seems that it can only be enabled/disabled at a page level. assuming I have to disable it at for the...
9
by: AFN | last post by:
I was just dropped into someone else's code (isn't that always so fun?). I can't figure out why a custom validation control's server event function is executing. There is nothing (that I see)...
9
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected......
5
by: Richard Brown | last post by:
Ok, I've been looking through the .NET SDK docs and stuff. I'm wondering if you can provide a control extender that does generic validation or functionality just by dropping it on the form. For...
10
by: John Richardson | last post by:
General question about how WinForms handles undoing a change during a control's validation, if it does at all. After a change to a control's value, if the data is determined to be invalid, then in...
12
by: Nalaka | last post by:
Hi, I suddenly started getting a lot of errors from html validation (some CSS) so I followed the following instructions to disable it. If you'd rather not have these types of HTML validation...
2
by: ticars | last post by:
I have a telephone number user control in which I need to validate the data entered (Required field validation and regular expression validation). The phone number is represented as 3 text boxes...
0
by: dhurwitz | last post by:
Hi, In my ASP.NET 2.0 web app, I have a user control, ucBinEdges, with several text boxes. The user control has several validation controls validating the Text of these text boxes -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.