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 519607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:03:31+00:00 2026-05-13T08:03:31+00:00

So it looks like if I add style such as background color to LinkButton

  • 0

So it looks like if I add style such as background color to LinkButton in my .cs code, it overrides any css I have that applies to it.

is there any way to add style rather than replace it in my code behind? Thanks!
I am using link button as a menu, so active linkButton should have different background color.
so my solution was when the user clicks on the link button in my event handler I do something like:

   lnkView.BackColor = System.Drawing.Color.FromName("#369");

But then my hover style which I have in my css will no longer work:

.navlist a:hover
{
    color: #fff;
    background-color: #369;
    text-decoration: none;
}

in my aspx:

<ul class="navlist">
        <li><asp:LinkButton ID="lnkView" runat="server">view</asp:LinkButton></li>
        <li><asp:LinkButton ID="lnkCreateNew" runat="server">create new</asp:LinkButton></li>
    </ul>
  • 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-05-13T08:03:32+00:00Added an answer on May 13, 2026 at 8:03 am

    EDIT: Your question is unclear, but you appear to be mis-understanding CSS. Adding background-color to the style property will not cause it to completely ignore any CSS rules. Rather, it will override any CSS rules for the background-color property, but will not affect any other rules.

    If you don’t want to override the background-color property from the CSS rule, add the !important flag to the CSS rule in :hover, like this:

    background-color: #369 !important;
    

    Also, change the color so that the change wil be noticable.

    Alternatively, you could add a new CSS rule for .navlist a:link .Active with your background color, then add the Active class in code. (lnkView.CssClass += "Active")

    By the way, instead of calling Color.FromName, you should write Color.FromArgb(0x33, 0x66, 0x99).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some code that looks like this: document.getElementById(error).style.display = 'block'; and when this
I have something that looks like the following: var someList = MockRepository.GenerateStub<IList<ISomething>>(); someList.Add(MockRepository.GenerateStub<ISomething>()); The
In my xaml I have something that looks like: <TreeView.ItemContainerStyle> <Style TargetType=TreeViewItem> <Setter Property=IsExpanded
I have a CMakeLists.txt file that looks like this: add_executable(exec1 exec1.c source1.c source2.c source3.c)
I have form, where some fields are looks like rows, so I can add/delete
I have a ticket management program that I am trying to add 'accordian' style
In one application I'm suddenly getting a style that looks like windows classics. It
The web designer has given me HTML which looks like: <div .... style=background: transparent
I'm trying add a tab to my web page that looks like this: Using
I have a page that looks like: <div id=header>...</div><div id=navigation>...</div> similar for body and

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.