Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For question 1, do not put your .datepicker() code in the bind event. Simply execute those on document ready:</p> <pre><code>&lt;script&gt; jQuery(document).ready(function ($) { $( "#Testdate-Field").datepicker(); $( "#TestdateTo-Field").datepicker(); }); &lt;/script&gt; </code></pre> <p>For your second question, use Html helpers to generate your inputs and then in your controller you can easily bind them: instead of using DisplayTextFor inside of input tags YOU generate, use TextBoxFor to generate the input tags for you:</p> <p>ViewModel:</p> <pre><code>public class SampleViewModel { // other properties here public DateTime SelectedDate { get; set; } public DateTime SelectedDateTo { get; set; } // other properties here } </code></pre> <p>View:</p> <pre><code>@model SampleClassViewModel @using(Html.BeginForm()) { @Html.TextBoxFor(m =&gt; m.SelectedDate, new { class = "datepickers" }) @Html.TextBoxFor(m =&gt; m.SelectedDateTo, new { class = "datepickers" }) &lt;input type="submit" /&gt; } &lt;script&gt; jQuery(document).ready(function ($) { $( ".datepickers").datepicker(); }); &lt;/script&gt; </code></pre> <p>There are many way to bind your properties, here are a couple... Controller option 1:</p> <pre><code>[HttpPost] public ActionResult SomeControllerAction(SampleViewModel model) { // do work... } </code></pre> <p>Controller option 2:</p> <pre><code>[HttpPost] public ActionResult SomeControllerAction() { var model = SomeServiceMethodToBuildModel(); this.TryUpdateModel(model); // do work... } </code></pre> <p>Thanks!</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. 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