I was hoping I could receive a little guidance on implementing a datepicker widget on an date input field.
I have downloaded the default datepicker package on the jQuery Site.
I have also tried numerous different ways found on different tutorial sites (including but not limited to: http://www.asp.net/m...pnet-mvc-part-4
http://blogs.msdn.co...validator.aspx)
In addition to these sites I have tried including the .js and .css files necessary. I have tried placing references to these files in numerous locations including: the Layout view within the shared folder (attempt 1), its own partial view and then using a @Html.Partial("partialViewNameHere") statement at the top of the view (attempt 2) and even just tried referencing the files I wanted at the top of the view itself inside <head></head> tags (attempt 3). I wanted the datepicker to appear and have not had any luck.
The reference statements I am using in attempt 1 and 2:
<link href="@Url.Content("~/Content/themes/jquery.ui.core.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/jquery.ui.datepicker.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/themes/jquery.ui.theme.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery.ui.core.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.datepicker.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/EditorHookup.js")" type="text/javascript"></script>
The reference statements I am using in attempt 3--correlates to this tutorial:
<head>
<link type="text/css" href="../../Content/jquery-ui-1.8.22.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="../../Scripts/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery-ui-1.8.22.custom.js"></script>
</head>
In addition to the reference fields here is the code I am trying to create the input field with and call the datepicker widget (located on the view that I want to display the datepicker on):
<input type = "text" name = "StartDate" id = "date" />
<script>
$(document).ready(function () {
$(".date").datepicker({ dateFormat: "dd/mm/yy" });
});
</script>
I have created a date.cshtml to be used by the datepicker:
@model DateTime
@Html.TextBox("", Model.ToString("dd/MM/yyyy"), new { @class = "date" })
Any advice on this would be much appreciated. I am not attached to any of the solutions. I was just trying different tutorials that I saw online to get something working.
This post has been edited by ItIntern3: 31 July 2012 - 08:36 AM

New Topic/Question
Reply



MultiQuote



|