I have a property which is set to required via data annotation. This works perfectly fine for the create form but I would like to make the property not required in the edit form. How can I go about doing that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can create seperate view models for create and edit views. You can keep the common properties in a common class and inherit those 2 view models from that common class.
And you can use these in your Action method like this
So your create view will be strongly typed to
CreateCustomerclass and edit view will be strongly typed toEditCustomerclass.Create.cshtml
Edit.cshtml