473,396 Members | 1,590 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,396 software developers and data experts.

preventing validation in OnClosing

Hi,

Anyone knows how to prevent the validating event of a control to be fired
when the user clicks the close button? The OnClosing event of the form seems
to be to late and setting the form's CausesValidation property to false
doesn't seem to help either...

Thanks...
Nov 16 '05 #1
1 1690
Alex,

The only suggestion I've seen from Microsoft is to go through your
entire form in your OnClosing event, setting CausesValidation on every
control to false. I consider this completely lame.

I suggest creating a bool flag in your form to act as a "don't bother
validating" flag:

private bool dontBotherValidating = false;

then every _Validating event handler looks like this:

private void aControl_Validating(object sender, System.EventArgs e)
{
if (!dontBotherValidating)
{
.... do validation stuff here ...
}
}

then, in OnClosing, you can add as the first line:

this.dontBotherValidating = true;

I know it's not pretty, but I have never found a way to flush pending
Validating events... you seem to have no choice but to have them fire,
so I just accepted that fact and handled the problem within my
Validating event handlers.

Nov 16 '05 #2

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

Similar topics

7
by: Robb Meade | last post by:
Hi all, A recent project that I had finished and went live with no apparant problems. My client received an email from a user who mentioned that by accident they had been typing (over the...
3
by: tshad | last post by:
I have a logon page that asks for a Logon and Password as well as a linkbutton that goes to register a new user. The problem is that if I push the submit button or the linkbutton to register a...
1
by: Lance | last post by:
I want to prevent a form from closing when the user clicks the form's Close button in the form's ControlBox (i.e., the button with the "X" in the upper-right corner of the form). Instead, I just...
1
by: Phill W. | last post by:
Has any come across a situation where, in a Form-derived .. er .. Form, the Event Arguments passed to OnClosing /already/ have their Cancel argument set to True? Protected Overrides Sub...
10
by: bregent | last post by:
I've seen plenty of articles and utilities for preventing form injections for ASP.NET, but not too much for classic ASP. Are there any good input validation scripts that you use to avoid form...
0
by: kbrolin65 | last post by:
Hi, folks. Please be patient, as I am not a programmer. But I wasn't sure where to turn for advice except for a programming discussion group. I am an intermediate PC user--fairly knowledgeable,...
4
by: AD | last post by:
Hi, I have 2 different web pages, both using RequiredFieldValidator's, on the one page Postbacks are prevented when required fields are blank, on the other page the validators display the error...
2
by: richard.martino | last post by:
Windows Experts: 1. I have a desktop application with a UserControl that contains controls: TextBoxes, RadioButtons, CheckBoxes and NumericUpDowns. 2. I want to warn the user that, if there is...
1
by: Steveaux | last post by:
Hi, I'm new to ASP.Net, so this may be something simple that I forgot. I have a form where a person can create a login. I'm doing the processing on this myself. The form has a plethora of...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.