提交表格时
RequestedDate
显示1/1/0001。原因是应用程序区域性是“en-US”,并且不支持“dd/MM/yyyy”格式。我无法将文化更改为“es-EC”。因为如果我将区域性设置为“es-EC”,则 NumericTextBoxFor
将值“169.90”发布为“16990”。
@(Html.Kendo().NumericTextBoxFor(x=>x.UnitPriceAnalyticCost)
.Format("c")
.Events(x => x.Change("unitPriceChange")
.Spin("unitPriceSpin"))
.Spinners(false)
.HtmlAttributes(new { style = "width:100%;cursor: not-allowed;pointer-events: none!important;color: black;font-color: black;background-color: #dddddd;", @readonly = true }))
@(Html.Kendo().DatePickerFor(m => m.RequestedDate)
.Value(Model.RequestedDate)
.Format("dd/MM/yyyy"))
是否可以映射在控制器上有效的“dd/MM/yyy”格式日期时间属性值?
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
var customCulture = new CultureInfo("en-US"); customCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
customCulture.NumberFormat.NumberDecimalSeparator = ".";
CultureInfo.DefaultThreadCurrentCulture = customCulture;
CultureInfo.DefaultThreadCurrentUICulture = customCulture;
}
这解决了我的问题。虽然我不能使用“es-EC”。