Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 是否无法在ASP.NET中选中服务器控件复选框?_Html_Css_Asp.net - Fatal编程技术网

Html 是否无法在ASP.NET中选中服务器控件复选框?

Html 是否无法在ASP.NET中选中服务器控件复选框?,html,css,asp.net,Html,Css,Asp.net,我试图在我的项目中创建一个切换按钮,当我添加一个服务器控件复选框时,复选框不能被选中,但是当我使用一个html控件并且该复选框可以被选中时,我缺少了什么 <div class="material-switch "> <asp:CheckBox ID="CheckBox1" runat="server" /> <label for="CheckBox1" class="label-primary" ></label>

我试图在我的项目中创建一个切换按钮,当我添加一个服务器控件复选框时,复选框不能被选中,但是当我使用一个html控件并且该复选框可以被选中时,我缺少了什么

<div class="material-switch ">
       <asp:CheckBox ID="CheckBox1" runat="server" />
       <label for="CheckBox1" class="label-primary" ></label>
    </div>

将属性的标签从“someSwitchOptionPrimary”更改为asp:CheckBox的id。工作示例如下:

<div class="material-switch">
    <asp:CheckBox ID="CheckBox1" runat="server" />
        <label for="CheckBox1" class="label-primary" ></label>
  </div>

好的。我明白了
我之所以会遇到这个问题,是因为当控件呈现到网页时,复选框的ID会发生变化…它会附加ctl00\u RightPlaceHolder\u,因为label控件无法找到该控件,因为它正在查找具有此ID“CheckBox1”的控件

因此,我添加了
clientdmode=“Static”
以使ID保持静态

谢谢

<div class="material-switch">
    <asp:CheckBox ID="CheckBox1" runat="server" />
        <label for="CheckBox1" class="label-primary" ></label>
  </div>