title: HTML Razor if statements not working
body: <p>I am working in a cshtml file using Razor syntax to create a calendar for a given month using a table. I have the following snippet of code as part of it:</p>
  
  <pre><code>@for(int i = 1; i &lt; ViewBag.numdays; i++)
  {
      if(true)
      {
          &lt;td&gt;@i&lt;/td&gt;
      }
  
      if(ViewBag.col == 6)
      {
          &lt;/tr&gt;&lt;tr&gt;
      }
  
      if(ViewBag.col == 6)
      {
          ViewBag.col = 0;
      }
      else
      {
          ViewBag.col++;
      }
  }
  </code></pre>
  
  <p>(Note I've checked while debugging that the two ViewBag variables have valid int values and they work elsewhere in the program)</p>
  
  <p>This code builds without any errors. However when I actually run it, it crashes in the browser. It sites the line containing the for statement as where the error occurred and says <i>The for block is missing a closing "}" character.  Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.</i> I also noticed that in Visual Studio, where it usually will highlight the closing bracket when the cursor is next to the opening bracket, it does not do that for the loop. In addition it also does not do it for any of the if statements inside except the first (I don't mean highlighting the wrong bracket, it just doesn't highlight anything). I'm really stuck as to what I'm doing wrong with the syntax here, any help would be greatly appreciated. Thanks.</p>
  
  <p>EDIT: I just realized the <code>if(true)</code> may look odd, at first I thought perhaps just creating the line of HTML within it then using if statements was the problem, so that was just an attempt to fix it, to no avail.</p>