title: How do you format a DateTime that's displayed by TextBoxFor() in MVC3?
body: <p>I have ASP.NET MVC3 installed. I need datepicker with formatted date. I tried this, but it's not working (when passing "{0:dd/MM/yyyy}" as format parameter, it still does not format):</p>
  
  <pre><code>    private static MvcHtmlString FormattedDateTextBoxFor&lt;TModel, TProperty&gt;(this HtmlHelper&lt;TModel&gt; htmlHelper, Expression&lt;Func&lt;TModel, TProperty&gt;&gt; expression, string format, RouteValueDictionary htmlAttributes)
      {
          var metadata = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData);
  
          if (metadata.Model != null &amp;&amp; metadata.Model as DateTime? != null)
              htmlAttributes.Add("value", string.Format(format, (DateTime)metadata.Model));
  
          return htmlHelper.TextBoxFor(expression, htmlAttributes);
      }
  </code></pre>
  
  <p>EDIT: My code works if format is "{0:dd-MM-yyyy}" but not only for "{0:dd/MM/yyyy}"</p>
  
  <p>I know that MVC4 has already this functionality, but unfortunately my project is written on MVC3. Can you help me?</p>