I am using the below Ajax form to select and post date ranges.
View Model:
public class ViewFormSubmissionsVM
{
public string FormName { get; set; }
public Guid FormId { get; set; }
[Display(Name="From:")]
public DateTime From { get; set; }
[Display(Name = "To:")]
public DateTime To { get; set; }
}
Razor/HTML:
@model ViewFormSubmissionsVM
@using (Ajax.BeginForm("ViewFormSubmissions", "Form", new AjaxOptions { HttpMethod = "POST", OnSuccess = "onGetSubmissionSuccess", OnFailure = "onGetSubmissionError" }, new { @class = "form-horizontal" }))
{
@Html.AntiForgeryToken()
@Html.HiddenFor(x => x.FormId)
<div class="row col-md-12">
<div class="pull-right">
<label class="control-label col-md-3">@Html.DisplayNameFor(x => x.From)</label>
@Html.TextBoxFor(x => x.From, "{0:MM/dd/yyyy}", new { @class = "form-control col-md-3", @data_picker = "date-picker" })
<label class="col-md-3">@Html.DisplayNameFor(x => x.To)</label>
@Html.TextBoxFor(x => x.To, "{0:MM/dd/yyyy}", new { @class = "form-control col-md-3", @data_picker = "date-picker" })
<input type="submit" class="btn btn-primary" value="Search" />
</div>
</div>
}
JQuery Date picker:
$(document).ready(function () {
$('*[data-picker="date-picker"]').datepicker();
});
This issue is while submitting the form, the "From" and "To" Datetime properties, received the default date values instead of selected.
Am I missing anything important!! I have already used these codes in different forms, but never experienced this before.
Could any one help me to get out of this one.
Many Thanks.