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

Set TextBox Background Color

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
Nov 19 '05 #1
3 1669
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..
"Wayne Wengert" wrote:
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

Nov 19 '05 #2
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.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Sat, 12 Feb 2005 08:56:46 -0700, "Wayne Wengert"
<wa***************@wengert.com> wrote:
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


Nov 19 '05 #3
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

"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:u6**************@tk2msftngp13.phx.gbl...
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

Nov 19 '05 #4

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

Similar topics

11
by: Mr. B | last post by:
While at first this may seem a simple tast, it has plagued me for a while... What I want to do is to have the background colour of something like a TextBox to change from (say) White to Yellow to...
3
by: Steve | last post by:
I have windows form with the few TextBox controls. Under certain conditions I disable or enable this controls by setting Enable property to true or false: For example: this.m_txtIP.Enabled =...
4
by: Jurjen de Groot | last post by:
I'm developing a ASP.NET/VB.NET web application. (VS.NET 2003) I've created several webpages, but on two pages one textbox colors yellow (the background) and I can't get the background to appear...
8
by: tshad | last post by:
I cannot seem to get the asp:textbox to use classes. Style works fine. I am trying to set the textbox to act like a label in some instance so it doesn't have a border, readonly and the background...
0
by: Don | last post by:
I'm making a custom control that has a multiline textbox on it. I want to make the textbox have a gradient background. On my custom control's Paint event I call a routine that draws a gradient on...
2
by: Simon | last post by:
I've only recently got started using VB.net Compact Framework, and I'm struggling to create a read-only Textbox with a white background. Even though I can set the background colour of a textbox,...
10
by: aarepasky | last post by:
I am using ASP Web 2005 express. I created the user control below and I am listing the html code. I have 2 textboxes. One is txtCompanyName. The main page has 2 panels on it and a button. ...
8
by: Filipe Marcelino | last post by:
Hi, I'm trying to create a textbox inheriting from the standard textbox. I would like to: 1. repaint the textbox border; 2. define a color for that border; Till now I made this:
0
by: sjickells | last post by:
Hi I am having a problem using asp:TextBox's in a transparent table. I have a background image on the page and a table in the middle of the page. I have set the background colour of the table...
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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.