Default value in an asp.net mvc view model
Set this in the constructor:
public class SearchModel
{
public bool IsMale { get; set; }
public bool IsFemale { get; set; }
public SearchModel()
{
IsMale = true;
IsFemale = true;
}
}
Then pass it to the view in your GET action:
[HttpGet]
public ActionResult Search()
{
return new View(new SearchModel());
}
Use specific value:
[Display(Name = "Date")]
public DateTime EntryDate {get; set;} = DateTime.Now;//by C# v6