title: How can I create a Html Helper like Html.BeginForm
body: <p>I have an Extension Method that verifies if the user is able to see a portion of the webpage, based on a Role.</p>
  
  <p>If I simple remove the content, this brings me more work as all the missing forms will not be correctly registered upon save and I have to deal with this behavior by modifying all my code, so I thought why not just use <code>display:none;</code> attribute?</p>
  
  <p>I would like to have something like:</p>
  
  <pre><code>@using(Html.RoleAccess(currentUser, RoleAccessType.Content_General_Website))
  {
      ...
  }
  </code></pre>
  
  <p>and that this would write something like:</p>
  
  <pre><code>&lt;div class="role_Content_General_Website" style="display:none;"&gt;
      ...
  &lt;/div&gt;
  </code></pre>
  
  <p>or use <code>display:block;</code> if the user has access...</p>
  
  <p>I can create a simple <code>HtmlHelper</code> but how do I write one that also outputs the ending <code>&lt;/div&gt;</code>?</p>
  
  <pre><code>public static string RoleAccess(
           this HtmlHelper helper, 
           UserInfo user, 
           RoleAccessType role)
  {
     return 
         String.Format(
              "&lt;div class='role_{0}' style='display:{1}'&gt;", 
              role.ToString(), user.HasAccess(role));
  }
  </code></pre>