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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:52:50+00:00 2026-05-24T08:52:50+00:00

I have some buttons on a page, around 10 asp buttons. I’m using a

  • 0

I have some buttons on a page, around 10 asp buttons. I’m using a CSS class for effects on button mouse hover and mouse leave. The problem I’m facing is that when I click a button, I want to apply a CSS class to the clicked button and want to keep it, but when I hover on that button the class is removed. Actually, I want to kind of disable the change of class for selected (clicked) button. So, if I have 5 buttons btn1, btn2, btn3, btn4, btn5 and my selected button is btn3, if I hover on btn3 and leave this btn3 , it should not loose its css class.

This is my code for applying CSS classes:

 <script src="jquery-1.6.2.js" type="text/javascript"></script>
    <script type="text/javascript">

        $(document).ready(function () {

            // mouse hover
            $("[id^='MangoPager_btn']").mouseenter(mouseenterfunction);
            // mouse leave
            $("[id^='MangoPager_btn']").mouseleave(mouseleavefunction);           

        });

        function mouseleavefunction() {

            $(this).removeClass("pagerbtnMouseEnter").addClass("buttonclass");
        }

        function mouseenterfunction() {

            $(this).addClass("pagerbtnMouseEnter");
        }

    </script>

and the code I’m using when a button is clicked:

     private void SetSelectedButtonStyle()
            {
ResetCss():
                //selectedItemClass 
                Button selectedButton = FindButtonWithText(_currentPageIndex.ToString());
                if (selectedButton != null)
                {
                    selectedButton.CssClass = "pagerbtnMouseEnter";
                }
            }

 private void ResetCss()
        {            

            for (int i = 1; i <= MAX_PAGE_SIZE; i++)
            {
                Button btn = (Button)FindControl(string.Format("btn{0}", i));
                btn.CssClass = "buttonclass";
            }
        }

I have to prevent the selected button from changing the CSS class when I do a mouse hover or mouse leave.

  • 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-24T08:52:50+00:00Added an answer on May 24, 2026 at 8:52 am

    You button has 3 different states :
    – Normal
    – Hovering
    – Selected

    Why do you only have 2 classes? If you wanna do that way you should have another css class for the pressed state, and then on your hovering functions you’ll check if your button has the selected class , and if it has then do nothing.

    But don’t you know that the hovering state is possible by css only?

    .myClass
    {
      background-color : blue;
    }
    
    .myClass:hover
    {
      background-color : red;
    }
    

    This will change the background color of a myclass element whenever your hover it.

    So what you can do is delete all your jquery code for the mouseenter / mouseleave

    Create a new class for the clicked state.

    .buttonClass
    {
       // Your button style
    }
    .buttonClass:hover
    {
       // Your mousein button style 
    }
    .buttonClicked
    {
       // Your selected/clicked button style
    }
    

    And on your asp.net page juste replace the .button class of the clicked button with the buttonClicked class 🙂

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

Sidebar

Related Questions

I have some buttons my page using a custom font face using the CSS
I have a page with some dynamically added buttons. If you click a button
I have to display yes/no button on some condition on my asp.net page ,
I have some options for pricing using radio buttons. When a user selects the
I have some images floating around in my SWF. The SWF holds several buttons,
I have got an ASP page that does some back-end processing. It calls a
I have a page with some generated HTML that survives the form's reset button.
I have some buttons in an UIView. My problem is, that they get cut
I have some filter and one grid.And grid have some buttons like modify/edit.I am
In my application I have some link buttons there but when I right click

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.