Bassem

Bassem

  • NA
  • 20
  • 6.7k

checkbox Server Control OnCheckedChanged

Mar 8 2011 6:15 AM
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>



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

checkbox serverside control doesnt hava  onclick event 

when i try to write this following , it dont run 

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





Answers (14)