title: Asp.Net Trying to get ClientID
body: <p>I'm a bit stuck trying to figure out how to pass a controls ClientID to one of my JavaScript methods.</p>
  
  <p>Edit:  I'm realizing I should mention this is an Asp.Net App built on .Net 3.5.  Can't use .Net 4.0 tricks but the 4.0 tricks you guys mentioned below in the replies are definately something to keep in mind and would solve this readily.</p>
  
  <p>When I do something like what follows, I end up having my Javascript method getting the literal text of &lt;%= gvCompanySelector.ClientID %> showing in my argument.</p>
  
  <p>Below is what my Asp.Net control looks like in the Aspx page.</p>
  
  <pre><code>&lt;asp:HyperLink ID="aShowList" runat="server" 
  onclick="javacript:showCompanySelector('divCompanySelector','&lt;%= gvCompanySelector.ClientID %&gt;');" 
  CssClass="button"&gt;Select&lt;/asp:HyperLink&gt;
  </code></pre>
  
  <p>my javascript method looks like this.</p>
  
  <pre><code>function showCompanySelector(divName,gridName) {
              var elem = document.getElementById(divName);
              var gridElem = document.getElementById(gridName);
              if (elem.style.visibility === 'visible') {
                  elem.style.visibility = 'hidden';
                  elem.style.height = '0px';
                  gridElem.style.height = '0px';
              }
              else {
                  elem.style.visibility = 'visible';
                  elem.style.height = '200px';
                  gridElem.style.height = null;
              }
          }
  </code></pre>
  
  <p>It's my gridName argument that's getting a value of &lt;%= gvCompanySelector.ClientID %> passed into it.  When I'm expecting the argument to show something like the ct100_blahlbah_gvCompanySelector ClientID.</p>
  
  <p>What kills me is that if I use just a standard Anchor tag, , the ClientID passes just fine.  </p>
  
  <p>And if the suggestion is to use an AddHandler or build the javascript call in my Code Behind, I'd like to avoid it.  I'm trying to have some sense of consistency in this code. =-/</p>
  
  <p>Thanks!</p>