简体   繁体   中英

Show linkbutton inside Repeater active on click

Generate A to Z linkbutton, I want to show alphabet linkbutton Active on Click. Either by Jquery or Code Behind.

<asp:UpdatePanel ID="UpdatePanel3" runat="server">
    <ContentTemplate>
        <asp:Repeater ID="rptAlphabets" runat="server">
            <ItemTemplate>
                <asp:LinkButton ID="lnkAlphabet" runat="server" Text='<%#Eval("Value")%>'  OnClick="Alphabet_Click" CssClass="listbtn" Width="31px" Height="15px" align="center"  CommandName="getalphabet" />

                <div class="clear-list">
                </div>

            </ItemTemplate>
        </asp:Repeater> 
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="rptAlphabets" />
    </Triggers>
</asp:UpdatePanel>

If you mean to highlight the selected button out of the groyp.. Yes you can do it using the CSS and JQuery..

use the below snippet...

 <style>
    .listbtn {
        border: 1px solid #bbb;
        border-radius: 2px;
        background-color: #eee;
        text-decoration: none;

        width: auto!important;
        padding: 3px;
    }
    .selected {
        background-color: #222;
        color: white;
    }
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $('.listbtn').click(function (e) {
            e.preventDefault();
            $('.listbtn').each(function () {
                $(this).removeClass('selected');
            });
            $(this).addClass('selected');

        });
    });
</script>

I am a little confused. But the code to enable a button would be something like. Button1.enabled=false; if(checkbox.checked) { Button1.enabled=true; }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM