Shalvin Interests

Wednesday, May 21, 2014

Html Input Type Date and MVC

View

<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%"><code>&lt;form method =&quot;post&quot; action =&quot;/&quot;&gt;
    &lt;input type =&quot;date&quot; name =&quot;calDOJ&quot; /&gt;
    &lt;div&gt;
        &lt;input type =&quot;submit&quot; /&gt;
    &lt;/div&gt;
&lt;/form&gt;
</code></pre>

Controller

 [HttpPost]
        public ActionResult Index(FormCollection fc)
        {
            DateTime dt =DateTime.Parse(  Request.Form["calDOJ"]);
            ViewBag.Hello = dt.ToString("D");
            return View();

        }