views:

34

answers:

2

I am storing a date in my database and want the user to be able to edit this date in the Edit View. In the past with ASP.Net web forms I have used 3 dropdownlists for the Month, Day and Year to get the date from the user and to bind it on display. I want to do the same in ASP.Net MVC and not sure how to do it?

I am not using any jQuery or Javascript, the design calls for simple postback.

+4  A: 

Please don't do it the way you used to. Three different drop-downs is not very user friendly.

jQuery is in the MVC project template by default. You can get some really nice date selection experiences using plug-ins (such as the linked datepicker). There is lots of documentation on how to get this working (and its really easy) so google this first.

Morten Mertner
+1 I agree with you on not doing it the way I used to. If I use jQuery, what happens if the JS is disabled by the user? They get a textbox to enter the date and I have to validate it on the ActionResult?
Picflight
Yes, but you have to do server-side validation regardless of how users input the value. Besides, I can't think of a single browser today that does not have a reasonable level of JavaScript support.
Morten Mertner
A: 

I found this blog that has pretty much what I had in mind and more examples for me to learn. Templated Helpers and Custom Model Binders in ASP.NET MVC 2

Picflight