Link to home
Start Free TrialLog in
Avatar of itgirl7
itgirl7

asked on

Textbox event

I ahve textbox  and label .I do have form.having 7 textbox with 7 label.

 Firstname : textboxfirstname
LAstname :textboxlastname
ETC.
Enter button.(Image button)
what I am trying to do is if any of the upper field is empty and anyone click the imagebutton than Label should turn into red and text into white.

then when someone add the text inside that and click anywhere or put the curser in nextbox the previous label have to becomes white again.

Can anyone pelase help me out.
Avatar of Deepak Lakkad
Deepak Lakkad
Flag of India image

You have yo write two events
1st for Image button, where you will check if textbox is empty then change font color of associated label e.g. Label1 is associated with TextBox1 then you will write code as below:
IF textbox1.text = "" Then
   Label1.BackColor = Color.Red
   Label1.ForeColor = Color.White
End If

Open in new window


same way you can code for other textboxes ...

2nd is Validate Event for TextBox ... The code snippnet is given below:
Label1.BackColor = Color.White ' or your original Back Color
Label1.ForeColor = Color.Black  ' or your original Fore Color

Open in new window


- Deepak Lakkad

Avatar of itgirl7
itgirl7

ASKER

Can you please let me know in which event I have to write.
ASKER CERTIFIED SOLUTION
Avatar of Deepak Lakkad
Deepak Lakkad
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial