MVC - Razor Edit and View mode implementation on Model(s) and Controller(s)
I have these different Razor views on my project:
- For editing: Image 1
- For view only mode: Image 2
What I want:
- Use only one View file Edit.cshtml for displaying or editing the models.
What I have:
- At the moment, I have 2 separate methods and views for editing/displaying the model.
What I could do (probably):
- Use one view for both, and conditionally display what I want/need in edit/display mode.
- But I've read that programmatically adding conditions of this kind on Razor, is not the best approach/practice.
So:
What can I do? How have you tackled this problem?
3 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
What do you mean? Are you talking about partial views?
Probably that's the best solution. But I was wondering if that's the best practice, and if it's not, what alternatives we have available.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View