У меня есть редактируемая страница, я хочу переформатировать большинство полей, скажем, у меня есть 2 поля, Пробег и Цена.Мне нужно отобразить их в TextBoxFor
Model.cs
public class TestModel {
[DisplayName("Mileage: ")]
[DisplayFormat(DataFormatString = "{0:##,###,###}")]
[RegularExpression(@"^(?:\d+|\d{1,3}(?:,\d{3})*)$", ErrorMessage = "*")]
public Int32 Mileage { get; set; }
[DisplayName("Price: ")]
[DataType(DataType.Currency)]
[DisplayFormat(DataFormatString = "{0:C}", ApplyFormatInEditMode = false)]
public Int32 Price{ get; set; }
}
Controller.cs
public ActionResult Index() {
var model = new TestModel();
model.Mileage=150000;
model.Price=21900;
return View(model);
}
Index.cs
@using (Html.BeginForm()) {
@Html.TextBoxFor(m => m.Mileage, new { @class = "w200" })
@Html.TextBoxFor(m => m.Price, new { @class = "w200" })
<input type="submit" />
}
К сожалению, я не вижу ни форматируемой цены, ни пробега.
Буду признателен за любую помощь как можно скорее,