You can check whether or not the ModelState is valid, but keep in mind that you're only checking the validity of the ModelState at the time the web request was made:
@if (ViewData.ModelState.IsValid) {
...
}
Additionally, you can check validatity of a property on the model in the view:
@if (ViewData.ModelState.IsValidField("FIELD_NAME")) {
...
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…