Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8672419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:11:57+00:00 2026-06-12T19:11:57+00:00

I would like to access the asp.net gridview’s cssClass attribute and change it with

  • 0

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';
}                  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:11:58+00:00Added an answer on June 12, 2026 at 7:11 pm

    Try this

    document.getElementById('<%=GridView1.ClientID%>').className = "class";
    

    And to add to existing class

    document.getElementById('<%=GridView1.ClientID%>').className += " class";
    

    Update

    function addClass()
    {
        var exClass = document.getElementById('<%=GridView1.ClientID%>').className;
    
        if(exClass.indexOf('className') == -1)  //check that the class does not already exist
        {
            if(exClass.length == 0)
               document.getElementById('<%=GridView1.ClientID%>').className += 'className'; //add
            else
               document.getElementById('<%=GridView1.ClientID%>').className += ' className'; //append
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class in my asp.net proj, I would like to get access
As I am a beginner to ASP.NET MVC, I would like to know what
I am binding a GridView using a DataSource in asp.net, and i would like
I would like to know if I create a database which is in asp.net
I would like to send json data using Ext.Ajax.request() then access it in ASP.NET
In ASP.NET MVC 3 I would like to access at database creation time the
How do you localize ASP.NET + javascript + Silverlight? I would like to be
I would like to access a MySQL database using PHP. Can someone please explain
I would like to extend IPrincipal in asp.net to allow me to get the
I am using the Html.DropDownList helper in ASP.NET MVC and I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.