复选框服务器控件OnCheckedChanged [英] checkbox Server Control OnCheckedChanged

查看:73
本文介绍了复选框服务器控件OnCheckedChanged的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有这段代码,它可以与输入复选框html contol完美运行

hello , i have this code and it run perfectly with input checkbox html contol

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script  language="javascript" type="text/javascript" >
              function chvisible(controlId)
                {
                    var control = document.getElementById(controlId);
                    if(control.style.display == "none" || control.style.display == "")
                        control.style.display = "block";
                        control.body.text="";
                    else
                        control.style.display = "none";
                }
</script>
        <asp:TextBox ID="TextBox1" runat="server" Style="display: none"></asp:TextBox>
        <input id="Checkbox1" type="checkbox" onclick="chvisible(''<%=TextBox1.ClientID %>'');"/>
</asp:Content>





当我更改< input>到CheckBox
我将写什么而不是"chvisible(''<%=TextBox1.ClientID %>'');"
在onCheckedChanged事件中?????

复选框服务器端控件没有onclick事件

当我尝试在下面编写此代码时,它不会运行





when i change the <input > to CheckBox
what i will write instead of "chvisible(''<%=TextBox1.ClientID %>'');"
in onCheckedChanged Event ?????

checkbox server side control doesn''t have onclick event

when i try to write this following , it don''t run

<asp:CheckBox ID="CheckBox2" runat="server" OnCheckedChanged="chvisible(''<%=TextBox1.ClientID %>'');" />



如果我写
也失败了



also it failed if i write

<asp:CheckBox ID="CheckBox1" runat="server" onclick="chvisible(''<%=TextBox1.ClientID %>'');" Text="sport" />

推荐答案

这样的更改-
change like this--
<asp:checkbox id="CheckBox2" runat="server" xmlns:asp="#unknown" />



现在在codebehind
的form_load中



now in form_load in codebehind

CheckBox2.InputAttribute.Add("onchange","chvisible(''" +TextBox1.ClientID + "'');")



--Pankaj



--Pankaj


复选框服务器端控件没有onclick事件

您可以将onclick事件添加为
checkbox server side control doesn''t have onclick event

You can add the onclick event as
CheckBox2.InputAttribute.Add("onclick","chvisible(''" +TextBox1.ClientID + "'');")


这篇关于复选框服务器控件OnCheckedChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆