0
我想显示日期只有没有时间,但似乎没有任何工作与MVC5。我需要使用TextboxFor而不是EditorFor。我试过:MVC5 TextboxFor显示日期没有时间
<td class="input-pricing">@Html.TextBoxFor(m => new ProjectPricing().UnitTypePriceEffDate,"{0:MM/dd/yy}", new {id = "model-effectiveDate", @class = "date" })</td>
它仍然显示时间。
UnitTypePriceEffDate is of DateTimeOffSet type.
我克隆模式jQuery中:
$("#model-pricing-row").clone().attr("id", "pricing-row-" + i).appendTo("#pricing-table");
$("#pricing-row-" + i + " #model-effectiveDate").attr("id", "effectiveDate-" + i);
$("#effectiveDate-" + i).attr("name", "Project.ProjectPricings[" + i + "].UnitTypePriceEffDate");
$("#effectiveDate-" + i).val(selectedUnitTypePriceEffDate[i]);
谁能帮助?谢谢!
你有没有试过用'EditorTemplate',例如'@model DateTimeOffset @ Html.TextBoxFor(m => m,“{0:MM/dd/yy}”,新的{@class =“date”})'? –
是的,但它不适用于MVC5。它完全忽略了“{0:MM/dd/yy}”... – BYG
问题似乎在这里'new ProjectPricing()。UnitTypePriceEffDate'。我试着用你的代码,没有时间显示日期。 – User3250