title: Umbraco 6 razor menu
body: <p>Hi I want to add a class of "active" to my li, if it is active or if I am on a page under that. I have the following code</p>
  
  <pre><code>@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
  @{
      Layout = null;
  }
  
  &lt;nav class="topNav"&gt;
      &lt;ul&gt;
          @foreach (var item in Model.Content.AncestorOrSelf(1).Children.Where(x =&gt; x.IsVisible() &amp;&amp; x.IsDocumentType("Subfrontpage") || x.IsDocumentType("Procesguide")))
          {       
              &lt;li&gt;
                  &lt;a href="@item.Url"&gt;@item.Name&lt;/a&gt;
              &lt;/li&gt;
          }
      &lt;/ul&gt;
  &lt;/nav&gt;
  </code></pre>
  
  <p>I think I can do something with this, but it gives an error</p>
  
  <pre><code>var isSelected = Model.Path.Contains(item.Id.ToString()) ? "active" : "";
  
              &lt;li class="@Html.Raw(isSelected)"&gt;
                  &lt;a href="@item.Url"&gt;@item.Name&lt;/a&gt;
              &lt;/li&gt;
  </code></pre>
  
  <p>This is the error I get. Line 10.</p>
  
  <pre><code>Compilation Error
  
  Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 
  
  Compiler Error Message: CS1061: 'Umbraco.Web.Models.RenderModel' does not contain a definition for 'Path' and no extension method 'Path' accepting a first argument of type 'Umbraco.Web.Models.RenderModel' could be found (are you missing a using directive or an assembly reference?)
  
  Source Error:
  
  
  Line 8:         @foreach (var item in Model.Content.AncestorOrSelf(1).Children.Where(x =&gt; x.IsVisible() &amp;&amp; x.IsDocumentType("Subfrontpage") || x.IsDocumentType("Procesguide")))
  Line 9:         {       
  Line 10:            var isSelected = Model.Path.Contains(item.Id.ToString()) ? "active" : "";
  Line 11: 
  Line 12: &lt;li class="@Html.Raw(isSelected)"&gt;
  </code></pre>
  
  <p>I have now tried with this, but no lunk</p>
  
  <pre><code>&lt;ul&gt;        
          &lt;li&gt;
              &lt;a href="@home.Url"&gt;@home.Name&lt;/a&gt;
          &lt;/li&gt;
  
          @foreach (var item in Model.Content.AncestorOrSelf(1).Children.Where(x =&gt; x.IsVisible() &amp;&amp; x.IsDocumentType("Subfrontpage") || x.IsDocumentType("Procesguide")))
          {       
  
  
              var isSelected = item.IsDescendant(Model,"active", "");
  
              &lt;li class="@Html.Raw(isSelected)"&gt;
                  &lt;a href="@item.Url"&gt;@item.Name&lt;/a&gt;
              &lt;/li&gt;
  
          }
  
  
      &lt;/ul&gt;
  </code></pre>