MVC - Toggling display options in a reused partial view -
i'm wondering correct way toggle visibility on partial view component, used multiple screens.
for example: if itemorder entity has these fields, , corresponding edit view has 3 input fields:
- cost - (only editable on page a)
- quantity - (don't show on page b)
- colour - (show disabled on page c)
and assume controllers these 3 pages each have own model root, e.g.:
- pageamodel
- itemorder
- pagebmodel
- itemorder
- pagecmodel
- itemorder
how can best control these view modes across these pages?
options come mind are:
- view model wraps itemorder entity, , has properties such ispriceeditable, iscoloureditenabled, etc? these set in controller.
- a itemorderviewoptions class inserted viewbag, , responsibility of each controller insert.
any suggestions on standard/recommended way this?
have @ can editortemplates similar along these lines:
create editortemplate each concrete type aka:
/editortemplates/pageamodel.cshtml /editortemplates/pagebmodel.cshtml /editortemplates/pagecmodel.cshtml
within these can explicitly control input fields like, each template used concrete type. have specified:
- cost - (only editable on page a)
- quantity - (don't show on page b)
- colour - (show disabled on page c)
then common page or seperate ones (as like) call:
@html.editorfor(m => m.thepagemodel)
which should render form have defined in editortemplates class type.
Comments
Post a Comment