Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 26th, 2004, 01:56 PM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default change background color of cell based on value

I built a very basic asp page that displays the contents of an access database in a table. It is a system status page, so one of the fields is either "UP" or "DOWN". I want to be able to make that cell's background color red when the value is DOWN. Can this be done with ASP?

  #2 (permalink)  
Old February 26th, 2004, 02:04 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,413
Thanks: 0
Thanked 16 Times in 16 Posts
Default

It's not a question of ASP, but of HTML.

Either set the table cell's background color:
<td bgcolor="#FF0000"></td>

Or you could use inline styles:
<td style="background-color:#FF0000;"></td>

Or you could use CSS:
<style>
TD.down{ background-color:#FF0000; }
</style>
<td class="down"></td>

I'd recommend using CSS as this is more standard and would reduce the overall HTML weight of your page.

Peter
------------------------------------------------------
Work smarter, not harder.
  #3 (permalink)  
Old February 26th, 2004, 02:06 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,413
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Then again, I just noticed this is in the ASPX forum. Are you using a datalist/grid for your data display? That would change things a bit.
  #4 (permalink)  
Old February 26th, 2004, 02:20 PM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes I am using a html table to display the data. I know how to change the color, but I only want to change the color when the value is DOWN. I.E. if the value is up, leave the color alone.

  #5 (permalink)  
Old February 26th, 2004, 03:52 PM
Registered User
 
Join Date: Feb 2004
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I figured it out. Just a basic if then statement works fine:

<% if rs.("field1") = "UP" then %>
<td><% = ("field1") %></td>
<% else %>
<td bgcolor="red"><% = ("field1") %></td>
<% end if %>


 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change background color using CSS pigtail Javascript How-To 9 April 4th, 2010 12:13 PM
change color of background meena88 C# 2005 3 December 1st, 2009 04:48 AM
change background color of inputbox vickriz Javascript How-To 3 December 1st, 2009 02:22 AM
Change the background color of a msgbox nobreferreira VB.NET 2002/2003 Basics 3 October 28th, 2004 10:37 AM



All times are GMT -4. The time now is 03:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.