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