How to catch Non-integer values mapped to integer properties in UpdateModel()?

I really like the approach of using a presentation model I'd create a class like this: class PersonPresentation { public int ID { get; set; } public string Name { get; set; } public string NumberOfCatsNamedEnder { get; set; } public void FromPerson(Person person){ /*Load data from person*/ } } Then your controller action can bind the view to a PersonPresentation: public ActionResult Index() { Person person = GetPerson(); PersonPresentation presentation = new PersonPresentation(); ViewData. Model = presentation. FromPerson(person); return View(); } and then accept one in your Update method and perform validation: public ActionResult Update(PersonPresentation presentation) { if(!IsInteger(presentation.

NumberOfCatsNamedEnder)) { ModelState. AddModelError( "NumberOfCatsNamedEnder", "Ender count should be a number"); } ... }.

I really like the approach of using a presentation model. I'd create a class like this: class PersonPresentation { public int ID { get; set; } public string Name { get; set; } public string NumberOfCatsNamedEnder { get; set; } public void FromPerson(Person person){ /*Load data from person*/ } } Then your controller action can bind the view to a PersonPresentation: public ActionResult Index() { Person person = GetPerson(); PersonPresentation presentation = new PersonPresentation(); ViewData. Model = presentation.

FromPerson(person); return View(); } ...and then accept one in your Update method and perform validation: public ActionResult Update(PersonPresentation presentation) { if(!IsInteger(presentation. NumberOfCatsNamedEnder)) { ModelState. AddModelError( "NumberOfCatsNamedEnder", "Ender count should be a number"); } ... }.

Asp.net mvc - How to catch Non-integer values mapped to integer properties in UpdateModel() - Stack Overflow.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions