How to recover all checkbox

Asked

Viewed 66 times

1

In the code below, I have already tried to recover all the checkbox but I can’t bring anything, I would not like to put the ID, but recover numerous checkbox selected, how can I do? I put only 2 as an example:(Code Behind)

<div class="form-group">                  
    <label for="teste" class="col-sm-2 control-label">teste</label>               
    <div class="col-xs-11 col-sm-6">     
        <asp:TextBox ID="teste" class="form-control" runat="server"></asp:TextBox>
    </div> 
    <div class="col-xs-1 col-sm-1">
        <asp:CheckBox ID="CheckMed" runat="server" />
    </div>        
    <div class="col-xs-1 col-sm-1">
        <asp:CheckBox ID="CheckSun" runat="server" />
    </div>
</div>        

  • 1

    You want this on the client or server?

  • Would be in the codebehind

1 answer

2

I think it’s not the best way, but you can find it that way:

CheckBox chkCheckMed= (CheckBox)PanelBar.FindControl("CheckMed");

PanelBar is just an example. You should place your items inside a Panel named after you to work as in this example. Note that using this way induces several errors. If for some reason the item’s ID is changed, for example, it will no longer find the object.

Remember that to use the checkbox, you need to call the UI.WebControls:

using System.Web.UI.WebControls;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.