title: Check length of String passed from Model
body: <p>I'm working in ASP.NET MVC and I'm having some issues checking, in my view, if a string passed from my Model is empty or not.</p>
  
  <p>I have a <code>&lt;p&gt;</code>-tag, inside a <code>&lt;div&gt;</code>,  like so:</p>
  
  <pre><code>&lt;div class="category-text"&gt;
      &lt;p class="sidebar-text"&gt;@Html.Raw(Model.Text)&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Which in some cases will hold text and in some cases won't, so I want the whole div containing this <code>&lt;p&gt;</code>-tag to not display IF the text is empty. I wrote a jQuery function for this:</p>
  
  <pre><code>if ($(".sidebar-text").text().length) {
      $(".category-text").show();
  }
  </code></pre>
  
  <p>This function seems to be working. If I for example hardcode "asd" into the <code>&lt;p&gt;</code>-tag and log it in the console it gives me "3", which is how I expect it to be working.</p>
  
  <p>My problem is that using <code>@Html.Raw(Model.Text)</code> always returns 0, which makes the whole <code>category-text</code> div not show. I know for a fact that Model.Text has value, and using <code>@Html.Raw(Model.Text)</code> somewhere else in my view proves that text is actually in the <code>Model.Text</code>-object.</p>
  
  <p>What am I missing?</p>