473,545 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

simple validation problem

Hello everyone,

I have placed simple validation through ErrorProvider Class on my textBoxes
to check whether ther r empty or not

Error Provider Class check and catches the error but it doesn't stop saving
the record. For instance if I click on any other button on the form it
doesn't stop user from doing so. How can I stop or restrict user to stay in
the textbox prebenting any other button or option to be clicked as long as
there is a valid entry in the textbox.
Hope everyone can understand myu problem

Here is the code for ur reference.
Private Sub txtuId_Validati ng(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles txtuId.Validati ng

If txtuId.Text = String.Empty Then

ErrorProvider1. SetError(txtuId , "UserId cannot be left blank")

txtuId.Focus()

Me.ActiveContro l = txtuId

e.Cancel = True

Else

ErrorProvider1. SetError(txtuId , String.Empty)

End If

End Sub

Waiting for Quick responce.
Abul Hasan
Nov 20 '05 #1
8 1269
Try using Validation Controls instead, I believe they cancel events if
triggered.
You can find information on using them here:
http://msdn.microsoft.com/library/de...torControl.asp

HTH,
Lars-Erik
"Abul Hasan" <st******@yahoo .co.uk> wrote in message
news:OR******** ******@tk2msftn gp13.phx.gbl...
Hello everyone,

I have placed simple validation through ErrorProvider Class on my textBoxes to check whether ther r empty or not

Error Provider Class check and catches the error but it doesn't stop saving the record. For instance if I click on any other button on the form it
doesn't stop user from doing so. How can I stop or restrict user to stay in the textbox prebenting any other button or option to be clicked as long as
there is a valid entry in the textbox.
Hope everyone can understand myu problem

Here is the code for ur reference.
Private Sub txtuId_Validati ng(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles txtuId.Validati ng

If txtuId.Text = String.Empty Then

ErrorProvider1. SetError(txtuId , "UserId cannot be left blank")

txtuId.Focus()

Me.ActiveContro l = txtuId

e.Cancel = True

Else

ErrorProvider1. SetError(txtuId , String.Empty)

End If

End Sub

Waiting for Quick responce.
Abul Hasan

Nov 20 '05 #2
Abul:
"Abul Hasan" <st******@yahoo .co.uk> wrote in message
news:OR******** ******@tk2msftn gp13.phx.gbl...
Hello everyone,

I have placed simple validation through ErrorProvider Class on my textBoxes to check whether ther r empty or not

Error Provider Class check and catches the error but it doesn't stop saving the record. For instance if I click on any other button on the form it
doesn't stop user from doing so. How can I stop or restrict user to stay in the textbox prebenting any other button or option to be clicked as long as
there is a valid entry in the textbox.
Hope everyone can understand myu problem

Here is the code for ur reference.
Private Sub txtuId_Validati ng(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles txtuId.Validati ng

If txtuId.Text = String.Empty Then

ErrorProvider1. SetError(txtuId , "UserId cannot be left blank")

txtuId.Focus()

Me.ActiveContro l = txtuId

e.Cancel = True

Else

ErrorProvider1. SetError(txtuId , String.Empty)

End If

End Sub

Waiting for Quick responce.
Abul Hasan

Two things...

If I'm reading this right you are calling the errorprovider either
way..That's not causing your problem but it doesn't seem like something
you'd want to do.

I took your code and if I click on a button, it will let it fire. However,
I can't click in another textbox. However, if you get rid of the call to
me.ActiveContro l and the txtUid.Focus, you can't click on the button or
anywhere else. By default, if you call e.cancel in validating, it won't let
you out of the textbox. You can 'click' on a button for instance, but it
won't do anything. Try taking those two lines of code out and see if that
doesn't fix it for you...
http://www.knowdotnet.com/articles/validation2.html

HTH

Bill

Nov 20 '05 #3
Thanks a lot

solved my problem.

Abul Hasan Lakhani. MCP

"Abul Hasan" <st******@yahoo .co.uk> wrote in message
news:OR******** ******@tk2msftn gp13.phx.gbl...
Hello everyone,

I have placed simple validation through ErrorProvider Class on my textBoxes to check whether ther r empty or not

Error Provider Class check and catches the error but it doesn't stop saving the record. For instance if I click on any other button on the form it
doesn't stop user from doing so. How can I stop or restrict user to stay in the textbox prebenting any other button or option to be clicked as long as
there is a valid entry in the textbox.
Hope everyone can understand myu problem

Here is the code for ur reference.
Private Sub txtuId_Validati ng(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles txtuId.Validati ng

If txtuId.Text = String.Empty Then

ErrorProvider1. SetError(txtuId , "UserId cannot be left blank")

txtuId.Focus()

Me.ActiveContro l = txtuId

e.Cancel = True

Else

ErrorProvider1. SetError(txtuId , String.Empty)

End If

End Sub

Waiting for Quick responce.
Abul Hasan

Nov 20 '05 #4
Cor
Hi Abul,

I tested this code and in my opinion it does everything as it should do.
Are you doing the saving from the same form as this?

I changed the code a little, but that is only because the way we makes them
here on this board.
It are not changes that has to do with your error as far as I can see.

Cor

Private Sub txtuId_Validati ng(ByVal sender As Object, ByVal e As
System.Componen tModel.CancelEv entArgs) Handles txtuId.Validati ng
If txtuId.Text = "" Then
ErrorProvider1. SetError(txtuId , "UserId cannot be left blank")
Cancel = True
Else
ErrorProvider1. SetError(txtuId , "")
End If
End Sub

Nov 20 '05 #5
Cor
cancel = e.cancel
Nov 20 '05 #6
hey cor

relax man i know lil bit of programming ;)

Abul.

"Cor" <no*@non.com> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
cancel = e.cancel

Nov 20 '05 #7
Cor
Hi Abdul,
relax man i know lil bit of programming ;)


But others can read this also who do not that much.
(Besides the ones who will tell me it to tickle me)

:-))

I had no doubt that you would see this.

Cor
Nov 20 '05 #8
* "Abul Hasan" <st******@yahoo .co.uk> scripsit:
I have placed simple validation through ErrorProvider Class on my textBoxes
to check whether ther r empty or not

Error Provider Class check and catches the error but it doesn't stop saving
the record. For instance if I click on any other button on the form it
doesn't stop user from doing so. How can I stop or restrict user to stay in
the textbox prebenting any other button or option to be clicked as long as
there is a valid entry in the textbox.
Hope everyone can understand myu problem


Set the controls' 'Enabled' property to 'False'.

--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Nov 20 '05 #9

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

Similar topics

21
3886
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email adresses and so on. I thought it might be a better way to programm an automated, dynamic form validation that works for all kinds of fields, shows the...
3
1630
by: Marc Llenas | last post by:
Hi there, I'm stuck on a validation function for a form and I cannot figure out what the problem is. The page is in ASP. Any ideas? The function being called is: <script language="JavaScript" type="text/javascript"> function checkform ( form ) {
3
2228
by: Kent Ogletree | last post by:
I am porting a Java XML Validation class over to C# and I am having a problem finding exactly what I need to acomplish the task. First I need to test for well formedness. I know this is usually something that does not need to be done, however in this case it is required. Is the best way to do this to validate to the schema and if no...
51
8225
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct code? many thx!
3
2821
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario: i have many webforms in a site, most with two different custom controls, one is a login module, the other is a generic data entry module. When there are no validation controls on the page there is...
2
1641
by: SimonH | last post by:
Hi All, I'm having problems getting a custom validator to work. I'm hoping someone could perhaps notice what I've missed. I only want to provide a server side validation method. The problem is basically that the method that I've designated as the validation routine never gets called so I can't do anything about potentially duff data. ...
18
3018
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How ??
9
3167
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... So the behavour is similar to a tab control. The user is expected to fill out required data on each of the panels before pressing a submit button...
3
3092
by: Eric Lilja | last post by:
Hello, this is an xml-file with a nested DTD. It validates, test-1- with-dtd.xml: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE persons > <persons> <person name="Eric Lilja" /> </persons>
0
7487
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7680
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7446
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7778
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5349
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3476
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1908
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1033
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.