asp.net mvc 5 - My datetime picker from my model is not working -
the datetime picker not showing in view me select date returndate.it wont give me little arrow select calendar (datetime picker) , fills in values. shows textbox contains : '0001/01/01 12:00:00 am'
in model returndate field:
[datatype(datatype.date)] [displayformat(dataformatstring = "{0:yyyy-mm-dd}", applyformatineditmode = true)] public datetime? returneddate { get; set; }
my view is:
<div class="form-group"> @html.labelfor(model => model.returneddate, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @html.editorfor(model => model.returneddate) @html.validationmessagefor(model => model.returneddate) </div> </div>
using jquery ui new view:
@model fcproject.models.purchase @{ viewbag.title = "create"; } <script src="~/scripts/jquery-ui-1.11.4.min.js"></script> @using (html.beginform()) { @html.antiforgerytoken() <h4>purchase</h4> <hr /> @html.validationsummary(true) <div class="form-group"> @html.labelfor(model => model.returneddate, new { @class = "control-label col-md-2", @id = "datepicker" }) <div class="col-md-10"> @html.editorfor(model => model.returneddate) @html.validationmessagefor(model => model.returneddate) </div> </div> <script> $(function () { $("#datepicker").datepicker(); }); </script> } @section scripts { @scripts.render("~/bundles/jqueryval") }
but still shows textbox no datetime picker.
if running on ie feature doesn't work, chrome works best on ui's.
but if still gives problem i'll suggest use jquery datepicker:
your view (modified):
<div class="form-group"> @html.labelfor(model => model.returneddate, new { @class ="control-label col-md-2", @id = "datepicker" }) <div class="col-md-10"> @html.editorfor(model => model.returneddate) @html.validationmessagefor(model => model.returneddate) </div> </div> <script> $(function() { $( "#datepicker" ).datepicker(); }); </script>
or visit
http://api.jqueryui.com/datepicker/
dont forget reference ui scripts e.g: (depending on script version)
<script src="~/scripts/jquery-ui-1.11.4.min.js"></script>
Comments
Post a Comment