title: How do I use Razor values in a javascript function?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4599169/using-razor-within-javascript">using razor within javascript</a>  </p>
  </blockquote>
  
  
  
  <p>I would like to place a siimple value from the model on a razor page and use it as a constant value in a javascript function.  i.e.</p>
  
  <pre><code>&lt;script&gt; var myValue = @Model.myRecord.Count();&lt;/script&gt;
  </code></pre>
  
  <p>so that myValue = the record count in my model. I am using myRecord.Count as an example, it could be any value from my model.</p>
  
  <p>Is this possible? </p>
  
  <p>TIA
  J</p>
  
  <p>OK I stumbled across the following solution:</p>
  
  <pre><code>&lt;script&gt; var myValue = @(Model.myRecord.Count())&lt;/script&gt;
  </code></pre>
  
  <p>Just putting inthe extra brackets helped.</p>