title: Javascript var with a newline using MVC Model property
body: <p>I have to set a Javascript variable to equal a property in my MVC model.</p>
  
  <p>I am doing this to detect if any changes were made to a textbox, this is setting the "original" value.</p>
  
  <p>My Javascript code looks like this:</p>
  
  <pre><code>var initVal = '@Model.ReferralHistoryDetail[1].ReferralComments';
  </code></pre>
  
  <p>I am getting an error, which I assume is due to this containing carriage returns in the comments.</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected token ILLEGAL
  </code></pre>
  
  <p>The HTML being rendered in this case is putting the closing quote on a newline, and that is the error being shown in the developer console.</p>
  
  <p>For example, the rendered HTML is:</p>
  
  <pre><code>        var initVal = 'blah blah blah
  ';
  </code></pre>
  
  <p>What is the proper way to handle this?</p>