title: How to find clientID of Datalist control using jquery?
body: <p>I have a DataList with a ModalPopupExtender control. When I click the div in datalist show ModalPopupExtender .</p>
  
  <pre><code>&lt;asp:DataList ID="AdsDataList" runat="server" RepeatColumns="4" 
                 RepeatDirection="Horizontal"&gt;
     &lt;ItemTemplate&gt;
       &lt;div class="Detail_Content" id="detailcontact" runat="server" 
            onclick="return OpenPopup();"&gt;
          &lt;label&gt;&lt;%# Eval("Name") %&gt;&lt;/label&gt;
       &lt;/div&gt;
       &lt;asp:Panel ID="Panel2" runat="server" Style="display: none;"&gt;
           &lt;div class="popup_block" style="width: 550px;left:30%;top:100px"&gt;
                &lt;label&gt;&lt;%# Eval("FatherCategoryName")                                
           &lt;/div&gt;
       &lt;/asp:Panel&gt;
          &lt;cc1:ModalPopupExtender runat="server" ID="ModalPopupExtender1" 
               TargetControlID="detailcontact" PopupControlID="Panel2" 
               PopupDragHandleControlID="header" DropShadow="false" 
               RepositionMode="RepositionOnWindowResizeAndScroll" X="400" Y="130" 
               BackgroundCssClass="modalBackground"CancelControlID="btnclose1" /&gt;
     &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>I want, when user click to background, hide ModalPopupExtender .</p>
  
  <p>I use this jquery code. but don't find ModalPopupExtender .</p>
  
  <pre><code>var modalWindow = $("[id*=AdsDataList] [id*=ModalPopupExtender1]");
  </code></pre>
  
  <p>and </p>
  
  <pre><code>$find('#&lt;%= AdsDataList.FindControl("ModalPopupExtender1").ClientID %&gt;');
  </code></pre>
  
  <p>but get error </p>
  
  <blockquote>
    <p>'Object reference not set to an instance of an object.'</p>
  </blockquote>
  
  <p>How to find clientID of Datalist control using jquery?</p>