title: JavaScript inside C#
body: <pre><code>&lt;script&gt;
   ...
  
     var Klasa = calEvent.ClassID;
     @{
       var NameOfClass = Model.FirstOrDefault(xx =&gt; xx.ClassID == @:Klasa).Nazwa_Klasy;
     }
  
    $description.append($('&lt;p/&gt;').html('&lt;b&gt;Klasa:&lt;/b&gt;' + @NameOfClass
  
   ...
  &lt;/script&gt;
  </code></pre>
  
  <p>How should I correct mix JS with C#? </p>
  
  <p>I get information 'Cannot use local variable "NameOfClass" before it is declared', </p>
  
  <p>but when I declare variable again before with string value then I get 'An opening "(" is missing the corresponding closing ")"' and then I am not sure what exactly I should do, because everything looks all right.</p>
  
  <p>My main target is that I want to get single data from Model (Nazwa_Klasy) where ClassID is equal calEvent.ClassID. Maybe should I also change my expression?</p>
  
  <p>Thanks for any answer!</p>