title: Find particular Checkbox from CheckBoxList via JQuery
body: <p>I have some trouble finding a particular Checkbox.
  In a dynamic asp.net CheckboxList with approximately 100 Checkboxes, I have a right click context menu and want to get the particular Checkbox on which I opened the context menu. </p>
  
  <pre><code>&lt;%= checkboxlist.ClientID%&gt;
  </code></pre>
  
  <p>only gets me the whole checkboxlist</p>
  
  <hr>
  
  <p>Here is my javascript/JQuery:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      function ShowMenu(control, e) {
          var posx = e.clientX + window.pageXOffset + 'px';
          var posy = e.clientY + window.pageYOffset - 10 + 'px';
          document.getElementById(control).style.position = 'absolute';
          document.getElementById(control).style.display = 'inline';
          document.getElementById(control).style.left = posx;
          document.getElementById(control).style.top = posy;
          var parent = document.getElementById('&lt;%= cbl_Machines.ClientID%&gt;');
      };
  
      function HideMenu(control) {
          document.getElementById(control).style.display = 'none';
      };
  
      $(document).on('click', '#divSelectAll', function () {
          $("INPUT[type='checkbox']").prop('checked', true);
          __doPostBack();
      });
  
      $(document).on('click', '#divDeselectAll', function () {
          $("INPUT[type='checkbox']").prop('checked', false);
          __doPostBack();
      });
  
      $(document).on('click', '#divAddMachine', function () {
          window.location.replace("../MemberPages/CreateMachine.aspx");
      });
  
      $(document).on('click', '#divModifyMachine', function () {
          alert('&lt;%=cbl_Machines.ClientID%&gt;');
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>And here is my HTML:</p>
  
  <pre><code>&lt;body&gt;
  &lt;div id="leftBox" onmousedown="HideMenu('contextMenu');"oncontextmenu="ShowMenu('contextMenu',event);"&gt;
      &lt;asp:CheckBoxList ID="cbl_Machines" Width="100%" RepeatLayout="Table" CssClass="cblmachines" runat="server" AutoPostBack="True" OnSelectedIndexChanged="cbl_Machines_SelectedIndexChanged" /&gt;
      &lt;div style="padding: 0px 5px; border: 1px solid black; border-top-style: none"&gt;
          &lt;asp:Button ID="btn_CreateMachine" Width="33%" runat="server" Text="Add Machine" OnClick="btn_CreateMachine_Click" /&gt;
          &lt;asp:Button ID="btn_ModifyMachine" Width="32%" runat="server" Text="Modify Machine" OnClick="btn_ModifyMachine_Click" /&gt;
          &lt;asp:Button ID="btn_DeleteMachine" Width="32%" runat="server" Text="Delete Machine" OnClick="btn_DeleteMachine_Click" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div style="display: none;" id="contextMenu" onmouseup="HideMenu('contextMenu');"&gt;
      &lt;table border="0" style="border: thin solid #808080; cursor: default; width: 150px; background-color: white"&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;div id="divSelectAll" class="ContextItem"&gt;Select All&lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;div id="divDeselectAll" class="ContextItem"&gt;Deselect All&lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;div id="divAddMachine" class="ContextItem"&gt;Add Machine&lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;div id="divModifyMachine" class="ContextItem"&gt;Modify Machine&lt;/div&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>And last but not least my Code Behind</p>
  
  <pre><code>        if (!Page.IsPostBack)
          {
              Configuration.DeserializeFromXMLMachines();
  
              var orderedList = Configuration.ManagedMachines.OrderBy(x =&gt; x.MachineName);
              foreach (var item in orderedList)
              {
                  cbl_Machines.Items.Add(item.MachineName+ "&lt;a class='HLdetails' href=\"MachineDetails.aspx?Name=" + item.MachineName + "\"&gt;&gt;&lt;/a&gt;");
              }
          }
  </code></pre>
  
  <p>When I right click in the 'leftBox' Div the following Context Menu appears</p>
  
  <p><a href="http://i.imgur.com/h4fqHye.jpg" rel="nofollow">http://i.imgur.com/h4fqHye.jpg</a></p>
  
  <p>And now when I click on Modify Machine I only need the value of this checkbox where the Context Menu opens. In this Case the one with the value Test24.</p>