Reputation: 12855
I have an enum view model property which I want to hide in the CREATE View but show in the LIST/Index View. The enum is Open,Failed,Succeeded.
Can this be done somehow with the HiddenInput attribute?
If this can not be done then I want at least to make it visible in both views, but disabled/another control (label instead of combobox).
I am using asp.net mvc 4.0
Upvotes: 0
Views: 193
Reputation: 1038830
Actually you should be using different view models. Remember: the first word of view model is view meaning that you define a view model per view. So you will have a CreateViewModel
that will be used for the Create
view without the enum property in question and a ListViewModel
with the enum property that will be used in the Index
view.
When doing code reviews I see many developers trying to reuse the same models over different views and ending up with some horrible logic because those models simply are not adapted for those views. They try to hide, they try to write ifs and stuff to perform validation, usually end up in a maintenance nightmare.
Upvotes: 1