views:

187

answers:

2

Consider i have 3 linkbuttons on a page,

<asp:LinkButton ID="LB1" runat="server" CssClass="regular" OnClick="LB1_Click">
      Today</asp:LinkButton>
 <asp:LinkButton ID="LB2" runat="server" CssClass="regular" OnClick="LB2_Click">
      Today</asp:LinkButton>
 <asp:LinkButton ID="LB3" runat="server" CssClass="regular" OnClick="LB3_Click">
      Today</asp:LinkButton>

I want to highlight a linkbutton on its click with a css and then remove its css when another linkbutton is clicked (ie) i want to show active link button. Any suggestion.

A: 

In Page_Load, you set the css class of all the linkbuttons to default class

LB1.CssClass = "StandardClass";
LB2.CssClass = "StandardClass";

....

And in the Btn_Click event of each LinkButton, you set its css class to the "Active" css

Eg : If LB1 is clicked then within LB1_Click

LB1.CssClass = "ActiveClass";

This seems straight forward enough. Hope i am not mis-understanding something in your question.

InSane
@Insane i ve done it with jquery any how thanks.
Pandiya Chendur
@Pandiya --- whoopsie!! :-) I just knew it wouldnt be something that simple!! Cant help with Jquery but maybe Omu's answer will do it for you!! BTW, maybe adding JQuery to the list of tags - would not confuse a relative noob like me!! :-)
InSane
+1  A: 

I'm using jquery-ui and I assign a class abtn to each button (input type=submit or a href)

I'n the page load I execute this:

function dobuttons() {
        $(".abtn").hover(
            function () {
                $(this).addClass("ui-state-hover");
            },
            function () {
                $(this).removeClass("ui-state-hover");
            }).bind({

                'mousedown mouseup': function () {
                    $(this).toggleClass('ui-state-active');
                }

            }).addClass("ui-state-default").addClass("ui-corner-all")
            .bind('mouseleave', function(){$(this).removeClass('ui-state-active')});
    }

you can see live sample here http://mrgsp.md:8080/a/Dossier/Create

Omu