HLRosenberger
asked on
Hilight a HTMLTable row when selected
How can I Hilight a HTMLTable row when selected? I know how to change the color, and I have code to find the row by ID, but how/where can I define handle a click event? I want to do this in the codebehind
This code hilights a row:
ctl = CType(Me.Page.FindControlR ecursively ("row"), HtmlTableRow)
If Not IsNothing(ctl) Then
' This will be used for each cell on the row.
Dim recordRowCell As System.Web.UI.HtmlControls .HtmlTable Cell
' Set the background color on the record row in RGB format.
Dim color As String = "#fff000"
' For each cell, set the background color.
For Each recordRowCell In ctl.Cells
' Override the record row background color -- since each data cell uses a
' style (by default: table_cell or table_cellr)
recordRowCell.Style.Add("b ackground- color", color)
Next
End If
This code hilights a row:
ctl = CType(Me.Page.FindControlR
If Not IsNothing(ctl) Then
' This will be used for each cell on the row.
Dim recordRowCell As System.Web.UI.HtmlControls
' Set the background color on the record row in RGB format.
Dim color As String = "#fff000"
' For each cell, set the background color.
For Each recordRowCell In ctl.Cells
' Override the record row background color -- since each data cell uses a
' style (by default: table_cell or table_cellr)
recordRowCell.Style.Add("b
Next
End If
ASKER
I do not want the change on hover over. I want to change the color on click. Yes, please provide the javascript for this. Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I wrote this today, is it what you're looking for? Client-side click?
http://www.codepal.co.uk/show/Highlight_a_Gridview_table_row_on_selection_using_JQuery
http://www.codepal.co.uk/show/Highlight_a_Gridview_table_row_on_selection_using_JQuery
ASKER
I do not know jQuery.
ASKER
thanks,.
Open in new window
I assume your table markup is like:
Open in new window
Note: Class mytable is only used to identify which table requires the css rule.I f you need to do this when user clicks the row, you can add Javascript onclick event and define a method that remove the class selectedrow from the selected row markup and added to the current row defined by the click event. Let me know if you want to go that path to provide the code and if you are using jquery. (VS2010 and VS2012 add this JS library by default to web projects)