title: Razor Partial View throwing Error unexpected <
body: <p>I have a razor Template which calls a partial view which in turns call another partial view.</p>
  
  <p>Template -> Introduction Row (partial View) -> (partial views that are in that row) Slider Partial, Box 1 - 4 partials.</p>
  
  <p>When I run the code I get an unhelpful error marked in the code below:
  <strong>INTRODUCTION ROW</strong></p>
  
  <pre><code>@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
  &lt;div class="wrapper row3"&gt;
      &lt;div id="container"&gt;
          &lt;!-- ################################################################################################ --&gt;
          &lt;div id="homepage" class="clear"&gt;
              &lt;div class="one_third first"&gt;
                  &lt;section class="main_slider"&gt;
                      @Html.Partial("IntroSlider")
                  &lt;/section&gt;
  
  
              &lt;/div&gt;
  
  
              &lt;div class="two_third"&gt;
                  &lt;div id="intro"&gt;
                      &lt;ul class="nospace center clear"&gt;
                          &lt;li class="one_quarter first"&gt;
                    &lt;!-- THE EXCEPTION IS THROWN ON THE NEXT LINE --&gt;
                              @Html.Partial("IntroBoxOne")
                          &lt;/li&gt;
                          &lt;li class="one_quarter"&gt;
                              @Html.Partial("IntroBoxTwo")
                          &lt;/li&gt;
                          &lt;li class="one_quarter"&gt;
                              @Html.Partial("IntroBoxThree")
                          &lt;/li&gt;
                          &lt;li class="one_quarter"&gt;
                              @Html.Partial("IntroBoxFour")
                          &lt;/li&gt;
                      &lt;/ul&gt;
                  &lt;/div&gt;
  
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;!-- ################################################################################################ --&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I am assuming the error is in the IntroBoxOne partial which follows:
  <strong>IntroBoxOne</strong></p>
  
  <pre><code>@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
  
  
  &lt;!--TODO: If no box'N'Content should we show the box at all? And if Not what size do we change any shown box to? --&gt;
  &lt;article class="boxholder rnd8"&gt;
  
      &lt;!-- Only show the top Image if one has been selected --&gt;
      @{
          if (!string.IsNullOrEmpty(@Umbraco.Field("topImageBoxOne").ToString()))
          {
              dynamic dynamicMediaItem = Umbraco.Media(Umbraco.Field("topImageBoxOne").ToString());
              &lt;div class="push30"&gt;&lt;img&gt;&lt;img style="max-width:30px;max-height:30px;" src="@dynamicMediaItem.Url" alt="@Umbraco.Field("boxOneAltText")"&gt;&lt;/div&gt;
          }
      }
  
  
      &lt;!-- Only show the Image if one is selected --&gt;
  
      @if (!string.IsNullOrEmpty(Umbraco.Field("boxOneIcon").ToString()))
      {
          dynamic dynamicMediaItem = Umbraco.Media(Umbraco.Field("boxOneIcon").ToString());
          &lt;span class="push30"&gt;&lt;img style="max-width:30px;max-height:30px;" src="@dynamicMediaItem.Url" alt="@Umbraco.Field("boxOneAltText")"&gt;@Umbraco.Field("boxOneTitle")&lt;/span&gt;
      }
  
      &lt;!-- Else only show the Title --&gt;
      else
      {
  
      &lt;span class="push30"&gt;@Umbraco.Field("boxOneTitle")&lt;/span&gt;
      }
  
  
      &lt;!-- Show the body content --&gt;
      &lt;p&gt;@Umbraco.Field("boxOneContent")&lt;/p&gt;
  
      &lt;!-- Only show the button if has text. --&gt;
      @{if (!string.IsNullOrEmpty(Umbraco.Field("boxOneIcon").ToString()))
      &lt;footer&gt;&lt;a href="#" class="button small gradient green rnd5"&gt;@Umbraco.Field("boxOneButtonText")&lt;/a&gt;&lt;/footer&gt;
      }
  
  &lt;/article&gt;
  </code></pre>
  
  <p>Knowing me and knowing I haven't done this kind of coding in ages the error is probably in the @If else block but I have tried numerous things to sort it; all to no avail.</p>
  
  <p><strong>UPDATE ONE:</strong></p>
  
  <p>The error is definitely in this part of the code:</p>
  
  <pre><code>@if (!string.IsNullOrEmpty(Umbraco.Field("boxOneIcon").ToString()))
      {
          dynamic dynamicMediaItem = Umbraco.Media(Umbraco.Field("boxOneIcon").ToString());
          &lt;span class="push30"&gt;&lt;img style="max-width:30px;max-height:30px;" src="@dynamicMediaItem.Url" alt="@Umbraco.Field("boxOneAltText")"&gt;@Umbraco.Field("boxOneTitle")&lt;/span&gt;
      }
  
      &lt;!-- Else only show the Title --&gt;
      else
      {
  
      &lt;span class="push30"&gt;@Umbraco.Field("boxOneTitle")&lt;/span&gt;
      }
  </code></pre>
  
  <p><strong>UPDATE TWO:</strong></p>
  
  <p>The Above IF ELSE statement throws an error but a double if statement like this succeeds:</p>
  
  <pre><code>@{
          if (!string.IsNullOrEmpty(Umbraco.Field("boxOneIcon").ToString()))
          {
              dynamic dynamicMediaItem = Umbraco.Media(Umbraco.Field("boxOneIcon").ToString());
              &lt;span class="push30"&gt;&lt;img style="max-width:30px;max-height:30px;" src="@dynamicMediaItem.Url" alt="@Umbraco.Field("boxOneAltText")"&gt;@Umbraco.Field("boxOneTitle")&lt;/span&gt;
          }
  
      &lt;!-- Else only show the Title --&gt;
      }
  
      @{
          if (string.IsNullOrEmpty(Umbraco.Field("boxOneIcon").ToString()))
          {
              &lt;span class="push30"&gt;   @Umbraco.Field("boxOneTitle") &lt;/span&gt;
          }
  
      &lt;!-- Else only show the Title --&gt;
      }
  </code></pre>
  
  <p>Clearly it is the syntax of the ELSE statement within the IF ELSE block that is wrong - but I have not found the solution other than two If statements.</p>
  
  <p>Anyone spot the not so deliberate mistake?</p>