473,404 Members | 2,137 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,404 software developers and data experts.

How to change a table cell's background color?

HB
So I have a table in ASP.NET

<table runat="server" id="tblMyTable">
<tr>
<td id="cellMyCell">word</td>
</tr>
</table>

How do I reference the cell "cellMyCell" from the Vb.NET 1.1 code-behind to
change the background color of the cell?
May 6 '06 #1
4 10717
HB
I forgot to add "without referencing row or cell numbers". I want to do it
by names, but the Rows(x).Cells(x) stuff just wants numbers. Yeah, I
could use an enum list but I'd like to know how to do this by "id" name.

"HB" <re**************@notreal.com> wrote in message
news:LE****************@tornado.socal.rr.com...
So I have a table in ASP.NET

<table runat="server" id="tblMyTable">
<tr>
<td id="cellMyCell">word</td>
</tr>
</table>

How do I reference the cell "cellMyCell" from the Vb.NET 1.1 code-behind
to change the background color of the cell?

May 6 '06 #2
Write a little utility method that will take the cell id as a parameter and
loop through the Rows and Cells collections. Likely, you can use the
FindControl method to find a cell within a row.

Eliyahu

"HB" <re**************@notreal.com> wrote in message
news:mv****************@tornado.socal.rr.com...
I forgot to add "without referencing row or cell numbers". I want to do it
by names, but the Rows(x).Cells(x) stuff just wants numbers. Yeah, I
could use an enum list but I'd like to know how to do this by "id" name.

"HB" <re**************@notreal.com> wrote in message
news:LE****************@tornado.socal.rr.com...
So I have a table in ASP.NET

<table runat="server" id="tblMyTable">
<tr>
<td id="cellMyCell">word</td>
</tr>
</table>

How do I reference the cell "cellMyCell" from the Vb.NET 1.1 code-behind
to change the background color of the cell?


May 7 '06 #3
HB
It seems there must be normal way to just reference the cell by its ID name.
Anyone know?
"Eliyahu Goldin" <re*************@monarchmed.com> wrote in message
news:OH**************@TK2MSFTNGP02.phx.gbl...
Write a little utility method that will take the cell id as a parameter
and loop through the Rows and Cells collections. Likely, you can use the
FindControl method to find a cell within a row.

Eliyahu

"HB" <re**************@notreal.com> wrote in message
news:mv****************@tornado.socal.rr.com...
I forgot to add "without referencing row or cell numbers". I want to do
it by names, but the Rows(x).Cells(x) stuff just wants numbers. Yeah, I
could use an enum list but I'd like to know how to do this by "id" name.

"HB" <re**************@notreal.com> wrote in message
news:LE****************@tornado.socal.rr.com...
So I have a table in ASP.NET

<table runat="server" id="tblMyTable">
<tr>
<td id="cellMyCell">word</td>
</tr>
</table>

How do I reference the cell "cellMyCell" from the Vb.NET 1.1 code-behind
to change the background color of the cell?



May 7 '06 #4
"HB" <re**************@notreal.com> wrote in message
news:Pt****************@tornado.socal.rr.com...
It seems there must be normal way to just reference the cell by its ID
name. Anyone know?


1) Make sure your <td /> includes the runat=server tag

2) Declare your tablecell object server-side - can't remember exactly how to
do it in VB.NET, but in C# it's

protected HtmlTableCell cellMyCell;

3) When you want to change the background colour, do something like:

cellMyCell.BackColor = Color.Red;
May 7 '06 #5

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

Similar topics

14
by: Reply Via Newsgroup | last post by:
Folks, Say I have a table, ten columns, ten rows - Each with a word in it. I want to change the values of some/all of the cells in the table via a hyperlink. How do I reference each cell and...
7
by: John A. | last post by:
Hello all! I've got a big bunch of pages using tables for layout. Eventually I'll get them set up with more modernized code, but in the meantime I'd like to slip in a little quick holiday...
1
by: Michael | last post by:
How can I use onclick to change a table cell background color. I know I can use this.className=? to change the classname. But then I would have to put the code into every single table cell. I...
2
by: Pete Kipe | last post by:
I'm not a JavaScript programmer...but I'm trying to put together a simple menu system for a new website and need a little help. I have the following script: <SCRIPT language=javascript> <!--...
3
by: michael | last post by:
I'm changing colors of table cells like this: <style type="text/css"> ..over {background-color: #bedddc} ..out {background-color: #99cccc} </style> <td onmouseover="this.className='over'"...
7
by: Keith Smith | last post by:
How can I change the background IMAGE (not just color) of a CELL in a table? I know that I can do this using CSS, but I really need to be able to do it using JavaScript. Anyone know how? Must...
3
by: Peter Williams | last post by:
Hi All, I want to write some javascript for a html page which does the following. Imagine that the page contains a table with 2 columns and 3 rows, e.g.: +---+---+ | A | B | +---+---+
1
by: vp.softverm | last post by:
hi all . Am facing problem with the date picker. when i click on date picker in a popup window. the date table is opened in the middle of the pop up window. and it is unable to scroll with...
2
by: Jim | last post by:
How can I use JavaScript to change a background image in a table cell? Here's the code for the cell <td width="338" valign="top" background="../images/ LEC_Q1.jpg"><div...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.