Html.TextBoxFor
needs a delegate, but you are passing it the result of calling String.Format
when String.Format
is passed a delegate.
You need to put the call to String.Format
(or, simpler, ToString
) inside the delegate:
<%: Html.TextBoxFor(model => model.IssueDate.ToString("d"), new { @class= "invoiceDate"}) %>
But as you note in your comment:
Gives this exception "Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions."
This is because Html.TextBoxFor
is expecting an Expression<T>
and decoding that to extract which property/method/field you are accessing. It will then use this information to later directly access the member.
You can either use Html.TextBox
, or add a property to your model type which includes the formatting.