Make cells in Table webcontrol 'clickable'?

P

Paul W

I'm using a Table webcontrol to display a 'grid' to the user. Various cells
should be 'clickable' by the user (to run javascript). How can I make this
happen? (currently I use the background cell color to indicate to the user
which cells are clickable).

(I think I could achieve this by adding an image (with attached hyperlink)
to each clickable cell but since this is a large table (7 x 30) I think this
might be a slow solution).

Thanks,

Paul.
 
G

Guest

Alternatively place a div inside the tablecell and you can handle the onclick
events.
HTH
srini
 
P

Paul W

Thanks. So would I add the DIV by adding a Literal control to the tablecell
(which I'm familiar with)?
If so, what would actually be inside the DIV? - I don't want to display any
text in the cells. I tried the following but it didn't work:

<div> onclick="myfunc(1,1)"</div>

I don't believe there's a DIV web control - have I missed it?

Paul.
 
K

Kevin Spencer

System.Web.UI.WebControls.Panel.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
C

Chris Simmons

Thanks. So would I add the DIV by adding a Literal control to the tablecell
(which I'm familiar with)?
Yes.

If so, what would actually be inside the DIV? - I don't want to display any
text in the cells. I tried the following but it didn't work:

<div> onclick="myfunc(1,1)"</div>

No, it would need to look like this:
I don't believe there's a DIV web control - have I missed it?

Not that I know of. I believe System.Web.UI.LiteralControl (as you
stated above) should get you what you want. Personally, I use
System.Web.UI.HtmlControls.HtmlGenericControl, but your way should
work as well.
 
P

Paul W

I'm familiar with panels, but not sure exactly what you intend. Should I add
a panel control to the tablecell's control collection?
What exactly do I first put in the panel?

Thanks,

Paul.
 
B

bruce barker

add a client side onclick to the td/th (cell)

cell.Attributes.Add("onclick","doCilck(this);");
 
K

Kevin Spencer

Hi Paul,

You wer asking:

A System.Web.UI.WebControls.Panel object renders a div on the client.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 

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,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top