title: Passing ASP.NET client IDs in to a javascript function
body: <p>I need to pass a client ID to a Javascript function in the onblur event of an ASP.net control event like this:</p>
  
  <pre><code>OnBlur="javascript:setBackground(this, '&lt;%= txtClientName.ClientID %&gt;')"
  </code></pre>
  
  <p>Here is my Javascript function:</p>
  
  <pre><code>function setBackground(sender, controlID) {
          sender.style.backgroundColor = "#ffffff";
          var nextElement = document.getElementById(controlID);
          if ((nextElement.value == '' || nextElement.value == 'Select') &amp;&amp; tab == true) {
              nextElement.style.backgroundColor = "#f7C059"
              tab = false;
          }
      }
  </code></pre>
  
  <p>The problem is that the client ID gets passed in literally as '&lt;%= txtClientName.ClientID %>' instead of the actual value. So, calling document.getElementById(controlID); doesn't work.</p>
  
  <p>How can I get the actual client ID and pass it to my Javascript function?</p>