title: Getting client ID using jquery
body: <p>Im trying to validate a textbox by getting the client ID using the below and then testing its value
  The textbox is in a ModalPopupExtender which is in a updatepanel
  However JQuery doesnt seem to be returning anything, the control is always NULL
  This textbox is inside a gridview</p>
  
  <pre><code>  &lt;asp:TemplateField HeaderText="Quick Donate"&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:Button ID="btnQuickDonate" runat="server"
                                          CommandName="Insert"
                                          CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;"
                                          OnClick="btnQuickDonate"
                                          Text="Quick Donate" /&gt;
                                      &lt;ajaxToolkit:ModalPopupExtender ID="ModalDonationPopup" runat="server" TargetControlID="btnQuickDonate" PopupControlID="Panel1" BackgroundCssClass="modalBackground"&gt;
                                      &lt;/ajaxToolkit:ModalPopupExtender&gt;
                                      &lt;asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none"&gt;
                                          Enter Donation Amount&lt;br /&gt;
                                          &lt;table&gt;
                                              &lt;tr&gt;
                                                  &lt;td&gt;&lt;/td&gt;
                                                  &lt;td&gt;
                                                      &lt;asp:Button ID="btnOnePound" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="1" /&gt;
                                                      &lt;asp:Button ID="btnFivePound" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="5" /&gt;
                                                      &lt;asp:Button ID="btnTenPound" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="10" /&gt;
                                                      &lt;asp:Button ID="btnFifteenPound" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="15" /&gt;
                                                      &lt;asp:Button ID="btnTwentyPounds" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="20" /&gt;
                                                      &lt;asp:Button ID="btnTwentyFivePounds" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="25" /&gt;
                                                      &lt;asp:Button ID="btnThirtyPounds" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="30" /&gt;
                                                      &lt;asp:Button ID="btnFiftyPounds" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" OnClick="btnQuickDonate" Text="50" /&gt;
  
                                                  &lt;/td&gt;
  
                                              &lt;/tr&gt;
                                              &lt;%--  --%&gt;
                                          &lt;/table&gt;
                                          &lt;br /&gt;
  
                                          &lt;asp:TextBox ID="txtFreeDonationAmount" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;"  &gt;&lt;/asp:TextBox&gt;
                                          **&lt;asp:Button ID="btnOK" runat="server" CommandArgument="&lt;%# ((GridViewRow) Container).RowIndex %&gt;" Text="OK" OnClientClick="return valtxtBoxFreeDonation();" OnClick="btnQuickDonate"&gt;&lt;/asp:Button&gt;**
                                          &lt;br /&gt;
                                          &lt;asp:Button ID="btnCancel" runat="server" Text="Cancel" /&gt;
  
                                      &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>Javascript below I have also tried $('#txtFreeDonationAmount') with no joy...</p>
  
  <pre><code>function valtxtBoxFreeDonation() {
      var txtDonation = $('#&lt;%=txtFreeDonationAmount.ClientID %&gt;');
  
       if (txtDonation.val().length &lt; 0) {
          // do something
          apprise("Please Enter a Donation Amount before click okay");
          return false;
      }
  
  }
  </code></pre>