Archive for January, 2015

mvc – feel my pain – view model is null on postback

January 17, 2015

I just spent two to three hours because I forgot to put get/set on the public members of my ViewModel.

The “etiology” (symptoms, bad behavior) was that my form posted back but the view model was always null.

Oops!

Correct:
public int logkey { get; set;}
public string logtitle { get; set;}
public string bywhom { get; set;}
public string slogdate { get; set;}
public DateTime logdate { get; set;}
public string logentry { get; set;}

I had been copying some working code, but not this part!