我的 cshtlm 页面包含以下代码:
@using (Html.BeginForm("Optional", "ConfigurationSilo2", FormMethod.Post, new { id = "storeDataForm" }))
{
@Html.TextBoxFor(x => x.Height)
<div align="right">
<input type="submit" id="Avanti" value="@ViewRes.ConfigurationString.buttonNext" name="@ViewRes.ConfigurationString.buttonNext" />
</div>
}
我的 html 生成的代码是:
<form action="/ConfigurationSilo2/Optional" id="storeDataForm" method="post">
<input data-val="true" data-val-number="The field Height must be a number." data-val-required="The Height field is required." id="Height" name="Height" type="text" value="0" />
<div align="right">
<input type="submit" id="Avanti" value="Next" name="Next" />
</div>
</form>
这是我的模型代码类:
public class Spondina
{
public int Height { get; set; }
public int Quantity { get; set; }
public float UnitPrice { get; set; }
public float TotalCost { get; set; }
}
为什么我的输入标签中有标签data-val data-val-number data-val-required ?