I have a table that i am generating using the ASP Table control and i am using a combination of CSS and javascript to make the table rows clickable. I use the CSS Code below to highlight the entire row and change the mouse to a pointer so it appears as a link:
table tr:hover{
background:#00ff90;
cursor:pointer;
}
I use the Javascript below to highlight the row that was selected.
function highlight(id) {
document.getElementById(id).className = "highlightthis";
}
If i code the html by hand for the table, it looks like this and it works.
<table>
<tr id="row1" onclick="highlight('row1')">
<td>col 1</td>
<td>col 2</td>
<td>col 3</td>
<td>col 4</td>
</tr>
<tr id="row2" onclick="highlight('row2')"&>
<td>col 1</td>
<td>col 2</td>
<td>col 3</td>
<td>col 4</td>
</tr>
</table>
However, i am not codding the html by hand, i am using the asp table control and VB code to generate each row and each cell in the table. my VB Code looks like this.
Private Sub DisplayAmortization()
tblamortization.Rows.Clear()
Dim row As New TableRow
Dim cell As New TableCell
Dim rc As String
For Each dr As DataRow In dtamortization.Rows
row = New TableRow
For i As Integer = 0 To dtamortization.Columns.Count - 1
cell = New TableCell
cell.Text = CType(dr(i), String)
cell.CssClass = "Column" & (i + 1).ToString
row.Cells.Add(cell)
Next
rc = "row" & CType(dr(0), String)
row.Attributes("Id") = rc
row.Attributes("onclick") = "highlight('" & rc & "')"
tblamortization.Rows.Add(row)
Next
tblamortization.Visible = True
tblamortization.CssClass = "Amortizationtable"
End Sub
in order to add the Id and onclick arrtibutes to the tr element, i am using the tablerow.attribute method. When this generates, it should generate code similar to
<tr id="row1" onclick="highlight('row1')">
, but when i run the code in a browser, and click on view source, asp replaces the single quotes with the html quote for a single quote " & # 39" as a result, by call to the javascript does not fire correctly. how can i get asp to dispaly the single quote instead of the code for a single quote?