I've added XDSoft's jquery-datetimepicker from NuGet, but am having a lot of trouble getting it to render on views.
I ended up trying to cobble some instructions together from http://xdsoft.net/jqplugins/datetimepicker/ (the page for the package) and http://www.codeguru.com/csharp/.net/net_asp/a-jquery-ui-based-date-picker-for-asp.net-mvc-5.html (which is for the jquery-UI package, but has a lot more generalised help) but cannot for the life of me figure out where I'm going wrong.
In BundleConfig.cs, I've added:
// datetime picker
bundles.Add(new ScriptBundle("~/bundles/datetime").Include(
"~/Scripts/jquery.datetimepicker.js"));
bundles.Add(new StyleBundle("~/Content/datetime").Include(
"~/Content/jquery.datetimepicker.css"));
Then in _Layout.cshtml, I've added:
@Styles.Render("~/Content/datetime")
and:
@Scripts.Render("~/bundles/datetime")
For good measure, in troubleshooting, I've tried adding those directly into the view in question as well, which is based off of the template for a create view.
So my understanding, is that then all I must do, is to set the class on the control to be "datetime". This doesn't work (appears as a normal textbox).
I then also tried using @Html.TextBoxFor()
instead, also to no avail. If I change the class to xdsoft_datetimepicker
instead, it leaves an empty gap rather than creating a text box, but obviously still not what I want either.
Any pointers, or links to a complete tutorial (not so much assumed knowledge like https://cuteprogramming.wordpress.com/2015/08/29/jquery-plugins-xdsoft-datetimepicker-and-jssor-slider/ , where it mentions adding a function, without saying where on earth I'm adding it or how) for showing a (browser agnostic) date-time picker for DateTime properties on the model would be greatly appreciated.
I also used ref
from codeguru website that you used. Check your js
and css
files are loading correctly when debugging. If not, use direct link referencing in your _Layout.cshtml
instead of bundling.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.