title: Using a HtmlHelper in MVC 5
body: <p>I am coding an <code>MVC 5</code> internet application, and I wish to display the <code>Id</code> of a <code>div</code> when using the <code>DisplayFor</code> method in a <code>view</code>.</p>
  
  <p>Here is some code that I have:</p>
  
  <pre><code>public static MvcHtmlString DisplayWithIdFor&lt;TModel, TValue&gt;(this HtmlHelper&lt;TModel&gt; helper, Expression&lt;Func&lt;TModel, TValue&gt;&gt; expression, string wrapperTag = "div")
  {
      var id = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(ExpressionHelper.GetExpressionText(expression));
      return MvcHtmlString.Create(string.Format("&lt;{0} id=\"{1}\"&gt;{2}&lt;/{0}&gt;", wrapperTag, id, helper.DisplayFor(expression)));
  }
  </code></pre>
  
  <p>This is the error that I am getting:</p>
  
  <blockquote>
    <p>'System.Web.Mvc.HtmlHelper' does not contain a definition for
    'DisplayFor' and no extension method 'DisplayFor' accepting a first
    argument of type 'System.Web.Mvc.HtmlHelper' could be found
    (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>I am not sure if I have placed the <code>DisplayWithIdFor</code> method in the correct place. I am wishing to use the <code>DisplayWithIdFor</code> method in the <code>Edit</code> <code>view</code> of a <code>controller</code> called <code>AssetController</code>, and have placed the <code>DisplayWithIdFor</code> method in the <code>AssetController</code>.</p>
  
  <p>Can I please have some help with this code?</p>
  
  <p>Thanks in advance.</p>