title: Calling an helper with linq expression capabilities
body: <p>I would like to transform my </p>
  
  <pre><code>&lt;input type="file" id="image" name="image"&gt;
  </code></pre>
  
  <p>with something like </p>
  
  <pre><code>@Html.UploadFor(model =&gt; model.Image)
  </code></pre>
  
  <p>Something more MVC friendly...</p>
  
  <p>I know that I have to create a helper for that with Linq Expression capabilities.</p>
  
  <p>How this can be done?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is one solution:</p>
  
  <pre><code>    public static MvcHtmlString UploadFor&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; helper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression)
      {
          var builder = new TagBuilder("input");
          builder.MergeAttribute("type", "file");
          builder.MergeAttribute("id", HtmlExtensions.IdFor(helper, expression));
          builder.MergeAttribute("name", HtmlExtensions.NameFor(helper, expression));
          return new MvcHtmlString(builder.ToString(TagRenderMode.SelfClosing));
      }
  
  public static class HtmlExtensions
  {
      public static string NameFor&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression)
      {
          return htmlHelper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(ExpressionHelper.GetExpressionText(expression));
      }
  
      public static string IdFor&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression)
      {
          return HtmlHelper.GenerateIdFromName(NameFor(htmlHelper, expression));
      }
  }
  </code></pre>