entity framework - Formatting Date on Html.TextBoxFor - other solutions not working -
using ef-generated classes, here's metadata class:
[displayname("approved date")] [datatype(datatype.datetime)] [displayformat(applyformatineditmode = true, htmlencode = false, nulldisplaytext = "", dataformatstring = "{0:mm/dd/yyyy}")] public object approveddate{ get; set; }
the view:
<%: html.editorfor(model => model.standard)%>
the editor:
<%:html.editorfor(model => model.approveddate)%>
the datetime.ascx:
<%string name = viewdata.templateinfo.htmlfieldprefix;%> <%string id = name.replace(".", "_");%> <div class="clear"> <div class="editor-label"><%:html.labelfor(model => model)%></div> <div class="editor-field"> <%:html.textboxfor(model => model)%> <%= html.validationmessagefor(model => model)%> </div> </div> <script type="text/javascript"> $(document).ready(function () { $("#<%=id%>").datepicker({ showon: 'both', dateformat: 'm/d/yy', changemonth: true, changeyear: true }); }); </script>
nothing seems work. have maintain binding, don't want raw html.
all date fields output same formatting, includes time.
3/12/2009 12:00:00am
what needs is
3/12/2009
thanks!
i ended using <%= html.textbox(null, string.format("{0:d}", model))%>
. seems work, , retains bindings.
Comments
Post a Comment