i've created , date editorfor template value getting lost on postback. please can help?
here's date.cshtml stored in 'shared/editortemplates' folder:
@model datetime <div class="input-append"> <input type="text" class="input-small datepicker" id="@viewbag.id" name="@viewbag.id" /> <span class="add-on"><i class="icon-th"></i></span> </div>
here's view:
@html.editorfor(m => m.requiredbydate, new { id = "requiredbydate" })
and property on viewmodel:
[display(name = "required date")] [required(errormessage = "required date required.")] [datatype(datatype.date)] public datetime requiredbydate { get; set; }
any appreciated.
i've not set value on input. idiot.
<input type="text" class="input-small datepicker" id="@viewbag.id" name="@viewbag.id" value="@model.tostring("dd/mm/yyyy")" />
Comments
Post a Comment