我有一个由表单和文本框组成的视图。如何在每个框中为字符串和 int 值设置默认值?
我希望页面加载每个框的值,所以我不需要输入值。
我无法更改模型中的任何内容。
@model MyDb.Production.ProductionMaterial
@{
ViewBag.Title = "CreateMaterial";
}
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>ProductionOrderMaterial</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Position)
</div>
<div class="editor-field"> //something like
@Html.TextBoxFor(model => model.Position, Or 5 )
@Html.ValidationMessageFor(model => model.Position)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.ArticleId)
</div>
<div class="editor-field"> //something like
@Html.TextBoxFor(model => model.ArticleId. Or "")
@Html.ValidationMessageFor(model => model.ArticleId)
</div>
}