1
我有我的下一個代碼cshtlm頁:HTML輔助TextBoxFor
@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 in my input tag?
如果您不想啓用客戶端驗證,則可以將「ClientValidationEnabled」和「UnobtrusiveJavaScriptEnabled」appSetting條目設置爲「false」。 –
不,我沒有** Height **的任何屬性。 – gorgonzola
你可以發佈你的視圖模型代碼? – levelnis