Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/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
Asp.net ASP CheckBox1\u CheckedChanged事件不工作。_Asp.net_Html_User Controls_Checkbox - Fatal编程技术网

Asp.net ASP CheckBox1\u CheckedChanged事件不工作。

Asp.net ASP CheckBox1\u CheckedChanged事件不工作。,asp.net,html,user-controls,checkbox,Asp.net,Html,User Controls,Checkbox,我只想在用户单击ASP页面中的复选框时看到一个Html表(id='xx')。一旦用户取消选中复选框,该表将再次不可见 <table> <tr> <td colspan='2'> <table id='xx'> <tr> <td colspan='2'>

我只想在用户单击ASP页面中的复选框时看到一个Html表(id='xx')。一旦用户取消选中复选框,该表将再次不可见

<table>
    <tr>
         <td colspan='2'>
               <table id='xx'>
                      <tr>
                          <td colspan='2'>
                                Student Information :
                           </td>
                           </tr>
                           <tr>
                           <td>
                             <asp:Label ID="Label1" runat="server" Text="Select Student name :"></asp:Label>
                           </td>
                           <td>
                              <asp:DropDownList ID="DropDownList1" runat="server" Width="200px">
                                   </asp:DropDownList>
                           </td>
                       </tr>
    ...
请帮帮我

试试这个

<table>
    <tr>
        <td colspan='2'>
            <asp:CheckBox runat="server" ID="CheckBox1" Text="check" Checked="true" AutoPostBack="true"
                OnCheckedChanged="CheckBox1_CheckedChanged" />
            <table id='xx' runat="server">
                <tr>
                    <td colspan='2'>
                        Student Information :
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Label1" runat="server" Text="Select Student name :"></asp:Label>
                    </td>
                    <td>
                        <asp:DropDownList ID="DropDownList1" runat="server" Width="200px">
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    this.xx.Visible = CheckBox1.Checked;
}

学生资料:
受保护的无效复选框1\u CheckedChanged(对象发送方,事件参数e)
{
this.xx.Visible=复选框1.选中;
}
试试这个

<table>
    <tr>
        <td colspan='2'>
            <asp:CheckBox runat="server" ID="CheckBox1" Text="check" Checked="true" AutoPostBack="true"
                OnCheckedChanged="CheckBox1_CheckedChanged" />
            <table id='xx' runat="server">
                <tr>
                    <td colspan='2'>
                        Student Information :
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="Label1" runat="server" Text="Select Student name :"></asp:Label>
                    </td>
                    <td>
                        <asp:DropDownList ID="DropDownList1" runat="server" Width="200px">
                        </asp:DropDownList>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
    this.xx.Visible = CheckBox1.Checked;
}

学生资料:
受保护的无效复选框1\u CheckedChanged(对象发送方,事件参数e)
{
this.xx.Visible=复选框1.选中;
}

使用AutoPostBack=“true”进行回发时的复选框控制。

使用AutoPostBack=“true”进行回发时的复选框控制。

这里有两个选项

  • 使用runat=“server”创建表服务器控件
  • 选中/取消选中复选框控件时,将显示属性设置为True/False
  • 服务器端的选项1句柄
    选项2客户端的句柄
    
    
    JavaScript函数

    <script language="javascript" type="text/javascript">
        function SelectChk(CtlId) {
            var IsChecked = document.getElementById(CtlId.id).checked;
            if (IsChecked) {
                document.getElementById(<%=xx.ClientID%>).style.display = 'block';
            }
            else{
                document.getElementById(<%=xx.ClientID%>).style.display = 'none';
            }
        }
    </script>
    
    
    函数SelectChk(CtlId){
    var IsChecked=document.getElementById(CtlId.id).checked;
    如果(已检查){
    document.getElementById().style.display='block';
    }
    否则{
    document.getElementById().style.display='none';
    }
    }
    
    这里有两个选项

  • 使用runat=“server”创建表服务器控件
  • 选中/取消选中复选框控件时,将显示属性设置为True/False
  • 服务器端的选项1句柄
    选项2客户端的句柄
    
    
    JavaScript函数

    <script language="javascript" type="text/javascript">
        function SelectChk(CtlId) {
            var IsChecked = document.getElementById(CtlId.id).checked;
            if (IsChecked) {
                document.getElementById(<%=xx.ClientID%>).style.display = 'block';
            }
            else{
                document.getElementById(<%=xx.ClientID%>).style.display = 'none';
            }
        }
    </script>
    
    
    函数SelectChk(CtlId){
    var IsChecked=document.getElementById(CtlId.id).checked;
    如果(已检查){
    document.getElementById().style.display='block';
    }
    否则{
    document.getElementById().style.display='none';
    }
    }
    
    Deepu:谢谢你的帮助。迪普:谢谢你的帮助。我忘了做那件事。
    <asp:CheckBox onclick="return SelectChk(this);" ID="chk" ></asp:CheckBox>
    
    <script language="javascript" type="text/javascript">
        function SelectChk(CtlId) {
            var IsChecked = document.getElementById(CtlId.id).checked;
            if (IsChecked) {
                document.getElementById(<%=xx.ClientID%>).style.display = 'block';
            }
            else{
                document.getElementById(<%=xx.ClientID%>).style.display = 'none';
            }
        }
    </script>