Make cells in Table webcontrol 'clickable'?

  • Thread starter Thread starter Paul W
  • Start date Start date
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.
 
Alternatively place a div inside the tablecell and you can handle the onclick
events.
HTH
srini
 
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.
 
System.Web.UI.WebControls.Panel.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
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.
 
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.
 
add a client side onclick to the td/th (cell)

cell.Attributes.Add("onclick","doCilck(this);");
 
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
 
Back
Top