0

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.

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

+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?
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.
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.