I am creating an mvc application which will allow me to add staff members, each staff member will have their own PIN number. Some how I need to ensure that that no PIN’s in my database are the same.
With mvc I pass the model from the view to the controller, model containing the staff members PIN. At the controller level its easier enough to test if the PIN already exists. Lets say I check if the PIN is valid or not and its not valid – how do I pass some kind of validation error back to the view to tell it that the PIN is invalid?
Thanks for any tips 🙂
You could add the error to the modelstate
and assuming that in your view you have a corresponding textbox and an error placeholder:
the error message will be shown.