I have a textbox that should accept datetime formats only. I am not sure how to convert this in MVC. I also want to know how to rearrange to a “yyyyMMdd” format, which is what needs to be passed.
<%=Html.TextBox("effectiveDate") %>
My controller has nothing :X
public ActionResult Index()
{
return View();
}
I know I am missing something… what is it?
I am not worried about entering a bad date right now… I just want to get the conversion concept.
For a strongly-typed model:
If it’s not a strongly-typed model (i.e. you have it in the ViewData), try this:
To demonstrate using the second method, change your controller code to this:
Make sure you check out the NerdDinner tutorials at http://nerddinnerbook.s3.amazonaws.com/Intro.htm