title: Why Date Format in ASP NET MVC Differs when used inside Html Helper?
body: <p>I just came across a very interesting issue. If I use ViewData to pass a DateTime value to the view and then display it inside a textbox, even though I'm using String.Format in the exact same manner, I get different formatting results when using the Html.TextBox helper.</p>
  
  <pre><code>&lt;%= Html.TextBox("datefilter", String.Format("{0:d}", ViewData["datefilter"]))%&gt;
  &lt;input id="test" name="test" type="text" value="&lt;%: String.Format("{0:d}", ViewData["datefilter"]) %&gt;" /&gt;
  </code></pre>
  
  <p>The above code renders the following html:</p>
  
  <pre><code>&lt;input id="datefilter" name="datefilter" type="text" value="2010-06-18" /&gt;
  &lt;input id="test" name="test" type="text" value="18/06/2010" /&gt;
  </code></pre>
  
  <p>Notice how the fist line that uses the Html helper produces the date format in one way while the second one produces a very different output. Any ideas why?</p>
  
  <p>Note: I'm currently in Brazil, so the standard short date format here is dd/MM/yyyy.</p>