B
Bob
Hi,
In the aspx file, i create a table:
<asp:Table ID="table1" runat="server">
</asp:Table></p>
In the code-behind, i defined a lot of cells with each an unique ID and some
of them a background color (red):
Dim r As TableRow
Dim c(x,y) As TableCell
For i = 0 To x
r = New TableRow()
For j = 0 To y
c(i, j) = New TableCell()
c(i, j).ID = j & ":" & i.ToString
c(i,0).BackColor = System.Drawing.ColorTranslator.FromHtml("red")
r.Cells.Add(c(i, j))
Next
Table1.Rows.Add(r)
Next
The purpose is: when the user clicks in the table, the backgroundclor of the
cell must be rendered which can generate some other action.
I did this in Javascript: (i want here the color of cell "2:2")
<script language="javascript" type="text/javascript">
function tableclick(event)
{
strid=window.event.srcElement.id
colo=document.getElementById("table1").rows[2].cells[2]style.background
alert(colo)
}
document.getElementById("table1").onclick = tableclick
</script>
But the alert gives always an empty window.
Thanks for any help.
Bob
In the aspx file, i create a table:
<asp:Table ID="table1" runat="server">
</asp:Table></p>
In the code-behind, i defined a lot of cells with each an unique ID and some
of them a background color (red):
Dim r As TableRow
Dim c(x,y) As TableCell
For i = 0 To x
r = New TableRow()
For j = 0 To y
c(i, j) = New TableCell()
c(i, j).ID = j & ":" & i.ToString
c(i,0).BackColor = System.Drawing.ColorTranslator.FromHtml("red")
r.Cells.Add(c(i, j))
Next
Table1.Rows.Add(r)
Next
The purpose is: when the user clicks in the table, the backgroundclor of the
cell must be rendered which can generate some other action.
I did this in Javascript: (i want here the color of cell "2:2")
<script language="javascript" type="text/javascript">
function tableclick(event)
{
strid=window.event.srcElement.id
colo=document.getElementById("table1").rows[2].cells[2]style.background
alert(colo)
}
document.getElementById("table1").onclick = tableclick
</script>
But the alert gives always an empty window.
Thanks for any help.
Bob