title: Convert Razor String Variable to Javascript String Variable in MVC
body: <p>I am trying to pass my string variable (even boolean) on my cshtml view to my javascript section. I can successfully pass the value from razor section to javascript if its integer. But what I want to accomplish is to pass the string value. Here is my sample code from my .cshtml:</p>
  
  <pre><code>string strAnnouncement = "My announcement";
  int intCounterValue = 1200;
  </code></pre>
  
  <p>To receive the value on Javascript, here is my code:</p>
  
  <pre><code>//Cannot get the value, always error on Developer Tool console
  var SessAnnouncement = @strAnnouncement;
  
  //Can get the value successfully
  var SessInitTimer = @intCounterValue;
  </code></pre>
  
  <p>As you can see, I can get the value via javascript on SessInitTimer which is 1200. But on SessAnnouncement, I get a <strong>Uncaught ReferenceError: My announcement is not defined.</strong></p>
  
  <p>How can I get the strAnnouncement value on my razor section and pass it on script section?</p>