そこで、jQueryUIの日付ピッカーを使用するASP.NetMVC3プロジェクトをIISサーバーに公開しました。日付ピッカーは値を投稿せず、バックエンドでデフォルト値に戻るようです。
地元では、それは魅力のように機能しますが。これは、datepickerにオプションがない単純なjQueryです。
なぜそれが起こるのかについての手がかりはありますか?
解決策を見つけるために投稿できるものを教えてください。
ありがとう!
私が投稿しようとしているモデル:
public class Report
{
[Required]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public DateTime From { get; set; }
[Required]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public DateTime To { get; set; }
public virtual Car Car { get; set; }
public virtual IEnumerable<Review> Reviews { get; set; }
}
私が使用しているフォーム:
@model Cars.Models.Report
<h3>Create a report</h3>
@using (Html.BeginForm("Generate", "Report"))
{
<div>
<div class="span-5">
<div class="editor-label">
@Html.LabelFor(model => model.From)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.From, new { @class = "datepicker lilbig" })
</div>
</div>
<div class="span-5 last">
<div class="editor-label">
@Html.LabelFor(model => model.To)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.To, new { @class = "datepicker lilbig" })
</div>
</div>
<div class="span-11 last">
<div class="prepend-5 last">
<input class="bigbtn" type="submit" value="Create" />
</div>
<div>
@Html.ValidationSummary(true)
@Html.ValidationMessageFor(model => model.From)
@Html.ValidationMessageFor(model => model.To)
</div>
</div>
</div>
}
私が投稿している方法:
[HttpPost]
public ActionResult Generate(Report model)
{
try
{
MembershipUser currentUser = Membership.GetUser(HttpContext.User.Identity.Name);
Guid id = (Guid)currentUser.ProviderUserKey;
Car currentCar = CarRepository.Get(id);
currentCar.LastReportCreated = DateTime.Now;
currentCar = CarRepository.Update(currentCar, true);
model.Car = currentCar;
model.Reviews = model.Car.Reviews.Where(s => s.LoggedAt.Date >= model.From.Date &&
s.LoggedAt.Date <= model.To.Date);
return View("Report", model);
}
catch(Exception ex)
{
return View("Error");
}
}
jQueryは次のようになります。
$(document).ready(function () {
$(".datepicker").datepicker();
});