title: How to get dynamic control checkbox in client side?
body: <p>In .net server side i was creating Dynamic controls text-box,checkbox. If i click the checkbox inside all the checkbox list controls it should get checked.
  refer this image.</p>
  
  <p>server side using new EventHandler i can achieve this.But i want this in clientside.</p>
  
  <p>Clientside code :</p>
  
  <pre><code>function CheckboxHeaderClick1() {
  
      var chkBox = "&lt;%=strchx1ID %&gt;";
      if (chkBox.checked) {
          var checkboxList = "&lt;%=strchxboxlist1ID %&gt;"; 
          var chkBoxCount = "&lt;%=strchxboxlist1Count %&gt;";
          for (var i = 0; i &lt; chkBoxCount.length; i++) {
              chkBoxCount[i].checked = true;
          }
      }
      else {
          var checkboxList = "&lt;%=strchxboxlist1ID %&gt;"; 
          var chkBoxCount = "&lt;%=strchxboxlist1Count %&gt;";
          for (var i = 0; i &lt; chkBoxCount.length; i++) {
              chkBoxCount[i].checked = false;
          }
      }
  }
  </code></pre>
  
  <p>but chkBox.checked is coming undefined.From server side to client side how i can pass the checkbox control?</p>
  
  <p>My code :</p>
  
  <pre><code>  Panel pnl1 = new Panel();
    chx1 = new CheckBox();
    chx1.ID = "chx" + fieldname;
    strchx1ID = chx1.ClientID;
    //   chx1.AutoPostBack = true;
    if (!IsPostBack)                                                                        
       chx1.Checked = true;
    // chx1.CheckedChanged += new EventHandler(this.chx1_CheckedChanged);
    // chx1.Attributes.Add("onclick", "CheckboxHeaderClick1();");
    chx1.Attributes.Add("onclick", "javascript:CheckboxHeaderClick1();return false;");
    checkboxID = chx1.ID;
    chx1.Style.Add(HtmlTextWriterStyle.BackgroundColor, "#f2f2f2");                                           
    chx1.Style.Add(HtmlTextWriterStyle.Color, "#287082");                                                                    
    chx1.Style.Add(HtmlTextWriterStyle.PaddingBottom, "6px");                                                                    
    chx1.Style.Add(HtmlTextWriterStyle.FontSize, "14px!important;");                                                                    
    pnl_filters.Controls.Add(chx1);                                                                    
  </code></pre>