title: How to deal with double quotes in JavaScript when referencing a C# variable
body: <p>I'm needing to call a JavaScript function that takes in a string variable that could have double quotes in it.  Here's how I pass my variable into the JavaScript function:</p>
  
  <pre><code>onclick="copyDescription('&lt;%# Eval("Description") %&gt;');"
  </code></pre>
  
  <p>The problem is the function never fires because it doesn't like the quotes that might be in the 'Description' variable.</p>
  
  <p>'Description', for example, could be:</p>
  
  <pre><code>VALVE BALL 1" 2000 RP THRD NACE SS BALON LS-10561
  </code></pre>
  
  <p>If I remove the double quote from the above description, it works great.  I further tested this out by doing the following, and it worked as expected:</p>
  
  <pre><code>        $(document).ready(function () {
          var str = 'VALVE BALL 1" 2000 RP THRD NACE SS BALON LS-10561';
          copyDescription(str);
      });
  </code></pre>
  
  <p>I tried doing a .replace('"','\"') and a .replace('"','') via JavaScript, but neither worked.  I can remove the quotes by modifying the C# code that gets the value to remove the double quote, and it works.  Just not through JavaScript.  Any ideas?</p>