Can i get help on datepicker functionality that i have tried by following the steps i got from internet using MVC4. The problem is that the calender does not display in a date textbox for user to choose a date but all refencing and JQuery codes are entered.
Here is my code on my model:
{public class Movies
{
public int ID { get; set; }
public string title { get; set; }
[DataType(DataType.Date)]
public DateTime releasedat { get; set; }
public string genre { get; set; }
public decimal price { get; set; }
}}
Here is the code for my controllers:
{public class JqueryController : Controller
{
//
// GET: /Jquery/
public ActionResult Index()
{
return View();
}
}}
Here is my code on top of a view to reference a datepicker script:
{@Scripts.Render("~/bundles/jqueryui")
<script >
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<h2>Date Time Picker</h2>
<p>Date: <input type="text" id="datepicker" /></p>}
I had also reference on my Start_App folder the relevant bundles, Here is my code:
{bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/jquery.validate*"));
bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css",
"~/Content/jquery-ui.css"));}
Also on my Layout I did add the JQuery script references, Her is my code:
{ @Styles.Render("~/Content/themes/base/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryval")}
--------------------------------Thanks--------------------------------------------------