Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <ol> <li>in _Layout.cshtml add following lines</li> </ol> <p>//CSS</p> <pre><code>&lt;link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.17/themes/redmond/jquery-ui.css" rel="Stylesheet" type="text/css" /&gt; </code></pre> <p>//SCRIPTS</p> <pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"&gt;&lt;/script&gt; </code></pre> <ol> <li><p>navigate to the Shared folder and there create a folder with a name EditorTemplates</p></li> <li><p>inside EditorTemplates folder create a partial view called DateTime</p></li> <li><p>add the following code to DateTime partial view</p> <p>@model System.DateTime ? @Html.TextBox("", (Model.HasValue ? Model.Value.ToShortDateString() : string.Empty), new { @class = "pickDate" })</p> <pre><code> &lt;script type="text/javascript"&gt; $(document).ready(function () { $('.pickDate').datepicker({ changeMonth: true, changeYear: true }); }); &lt;/script&gt; </code></pre></li> </ol> <p>Now you have everything set, and on every view where you have a field that is of DateTime type you'll see a jqueryUI datepicker when clicked inside that field or if you modify it's properties when clicked on icon etc.</p> <p>For an example your view is just as it's created from model, you don't need to add nothing to it.</p> <pre><code>&lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.DateOfBirth) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.DateOfBirth) @Html.ValidationMessageFor(model =&gt; model.DateOfBirth) &lt;/div&gt; </code></pre> <p><strong>UPDATE</strong></p> <p>You probably have some kind of scripts collison. Try adding</p> <pre><code>@if(false) { &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"&gt;&lt;/script&gt; } </code></pre> <p>on top of your view.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload