PeriodFrom = 05/10/2016
PeriodTo = 06/10/2016
以上属性日期格式为 dd / mm / yyyy ,如下面的屏幕截图所示。
但是,当我单击提交按钮时,值将被复制到视图模型。
PeriodFrom成为10/05/2016,PeriodTo成为10/05/2016
10成为日,5成为月。不知道为什么会这样。有人可以建议吗?
启动
var supportCultures = new[]
{
new CultureInfo("en-GB")
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-GB"),
SupportedCultures = supportCultures,
SupportedUICultures = supportCultures
});
查看
<form asp-controller="BragManagement" asp-action="Export" method="get" role="form">
<input type="hidden" asp-for="@Model.PeriodFrom" />
<input type="hidden" asp-for="@Model.PeriodTo" />
<input type="hidden" asp-for="@Model.BragValueTitle" />
<button type="submit" class="btn btn-pink">Export</button>
</form>
方式
[HttpGet]
public IActionResult Export(UserVoteDetailSearchViewModel model)
{
var result = _userRepository.GetAllUserVoteDetails(model);
_reportService.GenerateReport(result);
return View();
}
查看模型
public class UserVoteDetailSearchViewModel
{
public DateTime? PeriodFrom { get; set; }
public DateTime? PeriodTo { get; set; }
public string BragValueTitle { get; set; }
public List<UserVoteDetail> UserVoteDetailList { get; set; }
}