@Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui")
This example will add the functionality of the datepicker widget to a text box. First create a textbox and make sure it has the id attribute:
@Html.TextBoxFor(Function(x) x.ProposedStartDate, New With {.id = "ProposedStartDate"})
I recommend a separate jQuery file for each page that you add jQuery functionality. Create the file, and include a link to this file in your view:
<script type="text/javascript" src="~/Scripts/ViewjQuery/SampleView.js"></script>
In your jQuery files, associate your textbox with the widget by using the following code:
$(document).ready(function () { $("#ProposedStartDate").datepicker(); });
Finally, you're not going to like the look of the datepicker, so go to Theme Roller and download a jQuery theme .css file or two. Then reference this css file in the head tag of your layout file thusly:
<link href="~/Content/themes/lightness/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
Finally, you will be satisfied with the look of your datepicker, but you may want to size it down a bit. This has to be done through the font-size css style of a particular class. I don't recommend changing the theme .css that you downloaded. Rather, I would just create a new .css file for these types of tweaks and load it after you load the theme roller css. Put this in there:
.ui-datepicker { font-size:9pt !important}
No comments:
Post a Comment