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

CausesValidation Property Does Not Trigger Validate Event

I have simple app with a textBox, a button and errorProvider. I have all the
controls CausesValidation set to true, and the following code:

private void textBox1_Validation(object sender, CancelEventArgs e)
{
string error = null;
if( textBox1.Text.Length == 0 )
{
error = "Please enter a name";
e.Cancel = true;
}
errorProvider1.SetError((Control)sender, error);
}

This event fails to fire even though I tab over to another control without
putting anything in the textbox. I've researched the internet and have come
up empty. Does anyone know whether there is something that I am failing to
do. Thanks
Sep 10 '06 #1
1 2605
On Sat, 9 Sep 2006 22:50:02 -0700, Joseph <Jo****@discussions.microsoft.com>
wrote:
>I have simple app with a textBox, a button and errorProvider. I have all the
controls CausesValidation set to true, and the following code:

private void textBox1_Validation(object sender, CancelEventArgs e)
{
string error = null;
if( textBox1.Text.Length == 0 )
{
error = "Please enter a name";
e.Cancel = true;
}
errorProvider1.SetError((Control)sender, error);
}

This event fails to fire even though I tab over to another control without
putting anything in the textbox. I've researched the internet and have come
up empty. Does anyone know whether there is something that I am failing to
do. Thanks
Have you verified that there is no space character in the TextBoc control? Do
you have the form's AutoValidate property set properly?

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Sep 10 '06 #2

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

Similar topics

3
by: Lo?c Mah? | last post by:
Hello I try to use a Validator for a TxtCtrl placed in a Panel with a Button in order to trigger the Validator and test the content of TxtCtrl. I have looked into wxPython documentation and...
1
by: George Durzi | last post by:
I have an editcommandcolumn in my datagrid, as follows. <asp:editcommandcolumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"> I'd like to set the...
4
by: z. f. | last post by:
Hi, i stated that this is an advanced question because i have a post from few days ago that i received answers to with suggestions that looked good but did not work, so please if you post a...
2
by: Owin | last post by:
Hi all, I've created an User control. It's an extension of a textbox wich has some extra properties so that validation becomes a lot faster. The control wordks great if autopostback is on. When...
3
by: Martin | last post by:
Hi, I am implemeting a form in asp.net. The form is quite large and the validation is reasonably complex, so I have decieded to implement my own validation rather than use any custon...
2
by: dustbort | last post by:
I recently had a problem where my required field validator stopped working. But, the page still posted back and tried to insert a record into the database without performing server-side validation....
1
by: Sam Kong | last post by:
Hi, I want to trigger an event handler when a property changes. If the property is set via a function, it's simple to trigger the attached event handler. But if the property is set directly, I...
0
by: G | last post by:
Hello, There is no 'CausesValidation' property for the menu control in ASP.NET 2.0 or the menu item. Is there anyway to trigger the validation when a menu item is clicked ? Thanks, GSiry
0
by: =?Utf-8?B?RG91YnQgb2YgUmFqZWV2IEFN?= | last post by:
Dear all I require certain clarification on following line. This is regarding causesvalidation property of visualstudio 2005 controls. Iam using windows forms not web forms. Inorder to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.