Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC3 razor view error Microsoft JScript runtime error: Object doesn't support property or method 'datepicker'`
    primarykey
    data
    text
    <p>I am trying to display a datepicker for my Html.EditorFor</p> <p>To do this I created an EditorTemplate in my Views\Shared\EditorTemplate folder , Named it DateTime.cshtml</p> <p>but it is not working ,instead I am getting error ---<code>Microsoft JScript runtime error: Object doesn't support property or method 'datepicker'</code></p> <p>Plz help me to fix this error</p> <p>This is my razor view page</p> <pre><code>@model MyWebRole.ViewModels.ViewModelEvents @{ ViewBag.Title = "Create"; Layout = "~/Views/Shared/_Layout.cshtml"; } @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;fieldset style="width:50%"&gt; &lt;legend&gt;Event Details:&lt;/legend&gt; &lt;div&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; @Html.EditorFor(model =&gt; model.vmStartDate) @Html.ValidationMessageFor(model =&gt; model.vmStartDate) &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Save" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } </code></pre> <p>and here is my DateTime.cshtml (pasted below)</p> <pre><code>@model System.DateTime? &lt;div class="editor-field"&gt; @Html.TextBox("", String.Format("{0:MM/dd/yyyy}",(Model == DateTime.MinValue)? null : Model), new { @class="text"}) &lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function () { $("#@ViewData.ModelMetadata.PropertyName").datepicker({ changeMonth: true, changeYear: true, dateFormat: 'mm/dd/yy', gotoCurrent: true }); }); &lt;/script&gt; </code></pre> <p>I am able to get datepicker working on another view</p> <pre><code> @model MyWebRole.Models.Events @{ ViewBag.Title = "Edit"; Layout = "~/Views/Shared/_Layout.cshtml"; } @using (Html.BeginForm()) { @Html.ValidationSummary(true) &lt;fieldset style="width:50%"&gt; &lt;legend&gt;Event Details:&lt;/legend&gt; &lt;div&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt; @Html.EditorFor(model =&gt; model.StartDate) @Html.ValidationMessageFor(model =&gt; model.StartDate) &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;p&gt; &lt;input type="submit" value="Save" /&gt; &lt;/p&gt; &lt;/fieldset&gt; } </code></pre> <p>The difference between the two razor views is that -->the first one( (datepicker not working) is using a ViewModel as model ie(mywebrole.ViewModels.EventViewModel) </p> <p>--> and the second one is using the myWebrole.models.Events (datepicker working fine)</p> <p>Is this an issue ? </p>
    singulars
    1. This table or related slice is empty.
    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.
 

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