i. e How to apply validation on single property of a model while ignoring other(properties of that model) on if(modelstate.Isvalid){}???
Model
using System.ComponentModel.DataAnnotations;
namespace abc.Model
{
using System;
using System.Collections.Generic;
public partial class check_master
{
public int MCheck_id { get; set; }
[Required]
public string check_name { get; set; }
public string field { get; set; }
public Nullable<byte> max_length { get; set; }
public int check_id { get; set; }
}
}
View
@using (Html.BeginForm("addCheck", ""))
{
<input type="hidden" id="from" name="from" value="@ViewBag.from" readonly="readonly" />
<fieldset>
<tr>
<td>
@Html.DropDownList("check_master", "--select checks--")
</td>
<td>
@Html.TextBox("checkName", "")
@Html.ValidationMessage("check_name")
</td>
</tr>
</table>
</fieldset>
<p>
<input type="submit" value="Add" />
</p>
}
With
[Bind(Exclude = "Property_Name")]