Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is what i have done:
XML
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
                                <ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="TabPanel1">
                                    <HeaderTemplate>
                                        Pro
                                    </HeaderTemplate>
                                    <ContentTemplate>

                                        <div style="height: 100px; width: 200px; overflow: Auto">
                                            <asp:DataList ID="DataList1" runat="server" CellPadding="2" CellSpacing="2" ForeColor="Red">
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="checkbox" runat="server" AutoPostBack="true" OnCheckedChanged="checkLike_CheckedChanged" />
                                                    <asp:LinkButton Text='<%#Eval("UPP")%>' ID="lnkpro" runat="server" CssClass="linkbutton"
                                                        OnClick="btn_Click" CommandArgument='<%# Eval("UCode") %>'></asp:LinkButton>
                                                </ItemTemplate>


                                            </asp:DataList>
                                        </div>

                                    </ContentTemplate>
                                </ajaxToolkit:TabPanel>
                                <ajaxToolkit:TabPanel ID="TabPanel2" runat="server" HeaderText="services">
                                    <HeaderTemplate>
                                        Sets
                                    </HeaderTemplate>
                                    <ContentTemplate>

                                        <div style="height: 100px; width: 200px; overflow: Auto">
                                            <asp:DataList ID="DataList2" runat="server" CellPadding="2" CellSpacing="2">
                                                <ItemTemplate>
                                                    <asp:CheckBox ID="checkbox" runat="server" />
                                                    <asp:LinkButton Text='<%#Eval("SNA")%>' ID="lnkpro1" runat="server" CssClass="linkbutton"
                                                        OnClick="btn_Click1" CommandArgument='<%# Eval("Code") %>'></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:DataList>
                                        </div>
                                    </ContentTemplate>
                                </ajaxToolkit:TabPanel>
                            </ajaxToolkit:TabContainer>

Now my question :
This code block results in a list of link buttons in front of them all checkboxes. So what i want is to get the respective linkbutton value on checkbox checkchanged. Is it possible? for example
[] linkbtn1
[] linkbtn2
when i check on first checkbox the id not text of linkbutton1 should be fetched.([] is checkbox )
Posted

You can use JQuery for this purpose



JavaScript
$(document).ready(function () {
           $('#<%=checkbox.ClientID %>').change(function () {
               var optId = $(this).siblings("a").attr('id');
               alert(optId);
           });
       });


OR

JavaScript
  $(document).ready(function(){
    $("input[type=checkbox]").change(function(){
        if($(this).is(":checked")){
           var id = $(this).siblings("a").attr('id');
            alert(id);
           }else{
            alert("Unchecked")  
           }
        });

});
});
 
Share this answer
 
v4
Hi. Try like this in the server event.


C#
protected void checkLike_CheckedChanged(object sender, EventArgs e)
        {

            DataListItem datalistitem = (DataListItem)(sender as CheckBox).Parent;
            LinkButton lnkpro = datalistitem.FindControl("lnkpro") as LinkButton;
            string linktext = lnkpro.Text;
            string clientID = lnkpro.ClientID;


        }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900