I would like to access the asp.net gridview’s cssClass attribute and change it with Javascript.
I know I can access other individual style attributes like so:
document.getElementById('<%=GridView1.ClientID%>').style
But I’d like to change the cssClass in particular. This is what I have after attempting the first suggestion. It does not work as of yet. I placed that line you gave me in the first part of a function that highlights a selected row so that all previously highlighted rows would revert back to the normal style. Thoughts?
function ChangeRowColor(rowID) {
document.getElementById('<%=gvxTaskList.ClientID%>').className += "tablestyle";
var color = document.getElementById(rowID).style.backgroundColor;
if (color != 'yellow')
oldColor = color;
if (color == 'yellow')
document.getElementById(rowID).style.backgroundColor = oldColor;
else document.getElementById(rowID).style.backgroundColor = 'yellow';
}
Try this
And to add to existing class
Update