I have to make a large amount of forms for a project I’m working on. Every form has a large amount of fields in them. Would it be possible to create an HTML helper that can display an element or edit element depending on some variable? Maybe someone has tried this already. I could imagine that It would be something like:
@Html.EditOrDisplayFor(m=>m.Field, isReadonly)
When it is readonly it displays only the variable and when it is not it shows an textbox. Beside this helper I need some if’s in my views, but it saves a couple of 100 lines of code if this would be possible)
Just found an alternative (I think quite neat way) to do it: