0

I cannot figure out what control should I use to meet such requirements:

  • user can enter time (hh:mm)
  • user can delete some time from the list
  • time should be come to Action method in format (11:00, 13:00, 11:00 or 11:00 13:00 11:00 or if it is possible DateTime.ToString(HH:mm))

Maybe image will clarify what I mean:

enter image description here

I've tried to use Html.DropDownList but as far I understand that I cannot add time to this control in runtime.

What HTML helper or element should I use to meet such requirements?

StepUp
  • 36,391
  • 15
  • 88
  • 148
  • 1
    I usually forget about razor and/or HTML helpers and simply use the jQuery datetime picker and then send and receive the datetimes as JS or unix timestamps because the ASP.NET MVC controllers suck at receiving datetimes. This saved me a lot of headaches. – Rob Mar 31 '16 at 09:35
  • 2
    You can just have a 'add' button that generates a new texbox and associated delete button –  Mar 31 '16 at 09:41
  • @StephenMuecke maybe have some example to implement it? or link to see? or just answer at this question:) – StepUp Mar 31 '16 at 09:47
  • 1
    Some examples of dynamically adding and removing collection items [here](http://stackoverflow.com/questions/29161481/post-a-form-array-without-successful/29161796#29161796) and [here](http://stackoverflow.com/questions/28019793/submit-same-partial-view-called-multiple-times-data-to-controller/28081308#28081308) - although if your view is a simple as just adding and removing 'times' from a collection, then your case would be much simpler. –  Mar 31 '16 at 09:50
  • 1
    And your question suggests your times might be just one hour increments? - in which case, you could consider just displaying them all with an associated checkbox to select them (and it would mean no duplicates) –  Mar 31 '16 at 09:53
  • @StephenMuecke you are awesome! Thanks!:) – StepUp Mar 31 '16 at 10:04
  • @StepUp - was that you up-voting my recent answers? - it will likely be reversed as serial voting. –  Mar 31 '16 at 10:15
  • @StephenMuecke yeah:). Thanks for your help. :) – StepUp Mar 31 '16 at 10:32
  • 1
    All your votes were just reversed. You need to vote based on the merit of an answer, not for a user :) –  Apr 01 '16 at 03:41

0 Answers0