Split DateTime to Date and Time in ASP.NET MVC -


i have read through scott hanselman's post on topic. found another article seems simpler approach. second of decided try.

however, first portion in creating editortemplates not working me. copied datetime.ascx , timespan.ascx has author had them written. split fields in view.

    <div class="editor-label">         <%= html.labelfor(model => model.leaverequest.dateofleave)%>     </div>     <div class="editor-field">         <div class="date-container">             <%= html.textboxfor(model => model.leaverequest.dateofleave.date)%>         </div>         <div class="time-container">             <%= html.textboxfor(model => model.leaverequest.dateofleave.timeofday)%>         </div>         <div class="clear">             <%= html.validationmessagefor(model => model.leaverequest.dateofleave)%>         </div>     </div> 

the problem having behavior getting not same that author explained should happen. here screenshot of results.

screenshot showing full datetime in first field , zeros in second

i must missing something, can't tell what. have read article several times , can't see missing. guessing there needs tell program new editortemplates, don't know how.

you missed fact both scott's solution , solution link don't do:

<%= html.textboxfor(model => model.leaverequest.dateofleave.date) %> 

instead use:

<%= html.editorfor(model => model.leaverequest.dateofleave.date) %> 

and utilize custom editor limit field date (instead of both date , time).

scroll down separate date / time fields header of article link , read little bit closer custom editor templates.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -