Before you return your model from the controller, set your ReturnDate
property to DateTime.Now()
myModel.ReturnDate = DateTime.Now()
return View(myModel)
Your view is not the right place to set values on properties so the controller is the better place for this.
You could even have it so that the getter on ReturnDate
returns the current date/time.
private DateTime _returnDate = DateTime.MinValue;
public DateTime ReturnDate{
get{
return (_returnDate == DateTime.MinValue)? DateTime.Now() : _returnDate;
}
set{_returnDate = value;}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…