2016-07-07 163 views
0

我有2复选框的问题,任何想法如何获得用户选择使用C#值?复选框,获取用户选择值

<div class="form-group"> 
     <label for="checkboxes" id="checkbox123" style="text-align:left;color:black">2) How much of the training can you recall?</label> 
     <div> 
      <label class="checkbox-inline" for="checkboxes-0"> 
       <input type="checkbox" name="checkboxes" id="checkboxes-03" value="1"> 
       All of it 
      </label> 
      <label class="checkbox-inline" for="checkboxes-4"> 
       <input type="checkbox" name="checkboxes" id="checkboxes-43" value="5"> 
       Not at all 
      </label> 
     </div> 
    </div> 

    <div class="form-group"> 
     <label for="checkboxes" id="checkbox456" style="text-align:left;color:black">2) Are you ok?</label> 
     <div> 
      <label class="checkbox-inline" for="checkboxes-0"> 
       <input type="checkbox" name="checkboxes" id="checkboxes-03" value="1"> 
       Yes 
      </label> 
      <label class="checkbox-inline" for="checkboxes-4"> 
       <input type="checkbox" name="checkboxes" id="checkboxes-43" value="5"> 
       No 
      </label> 
     </div> 
    </div> 

上面的代码是我的复选框code.please引导我,谢谢。

回答

0

我在代码中看不到ASP.net控件。所有控制都是客户端 - 所以你无法访问代码隐藏。要在您的.cs访问元素文件,你需要设置runat="server"

更换

<label class="checkbox-inline" for="checkboxes-0"> 
     <input type="checkbox" name="checkboxes" id="checkboxes-03" value="1"> 
      All of it 
</label> 

<asp:CheckBox ID="cbAllofit" runat="server" Text="All of it" Checked="true" CssClass="checkbox-inline"/> 

和访问它在您的.cs

bool checked = cbAllofit.Checked;