I want to update the user profile in asp.net MVC but modelstate is not true, In View Model, I have added all details like
u_id
username
firstname
lastname
email
password
now i only want to update firstname and lastname I think that's model is not valid Lkindly give me suggestion/Solution to resolve this
CodePudding user response:
You can check and get the errors of the invalid ModelState with the following code:
var errors = ModelState.Select(x => x.Value.Errors).ToList();
Otherwise returning the ViewModel will show the validation errors.
CodePudding user response:
What I would suggest is to have model with
Id ,first-name,lastname post it to controller
In controller find user with that corresponding Id an
Update users first name an last name with new values and save the user profile
