Html.TextBoxFor format and css class

Filip picture Filip · Jan 22, 2011 · Viewed 60.4k times · Source

The two lines of code below work fine, but I want to combine them. What I mean is: I want to use the @class in the first code line. How can I do that?

<%: Html.TextBoxFor(model => model.Product.Price, String.Format("{0:f}", Model.Product.Price))%>

<%: Html.TextBoxFor(model => model.Product.Name, new { @class = "textBox150" })%>

thanks,

Filip

Answer

Cheddar picture Cheddar · Apr 13, 2011

I know I'm way late here but I just found a solution to this issue:

<%: Html.TextBoxFor(model => model.StartDate, new { @class = "datepicker", Value=String.Format("{0:d}", Model.StartDate) })%>