Set TextBox Background Color

W

Wayne Wengert

I am treying the change the background color of textboxes that have invalid
data. I am trying the code shown below but when I run it, I get an
exception?

Any thoughts on why this doesn't work?

Wayne

=================================
Dim normColor As Color = System.Drawing.Color.White

txtLastName.BackColor = normColor
 
G

Guest

Hmm, That sounds interesting...

Do it this way.
txtLastName.BackColor = System.Drawing.Color.White

By the way, What is the exception being thrown... Also do post the code..

Happy Coding..
 
S

Scott Allen

It looks like the code is fine - anychance the exception is a
NullReferenceException? If so, I'd make sure txtLastName is actually
attached to a control on the web form.
 
W

Wayne Wengert

I had a preceding statement that was supposed to be setting the contents of
a text box into a variable and I had left off the ".Text" The exception
really was caused by that. The reported line number was apparently off by 1?

Thanks for the speedy responses.

Wayne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top