Is there a way how to have template partial view, that would do just one job repeatedly but only one thing would be changing in the partial view so it could be used across multiple Views with different Models and not care about the Controller?
The Partial view would receive a bool from a View Model, depeding on the parent View. The bool from model would be used into the same positions always.
@Html.LabelFor(Model => Model.Bool1, new { @class = "class" })
@Html.RadioButtonFor(Model => Model.Bool1, true, new { @class = "class"})`
I would be passing the bool name into the partial view at the call of it.
@Html.Partial("_RadioButton", Model.Bool1})
Now, How do I do that to keep Bool changeable. As for example call the same partial in different View with different model as for example.
@Html.Partial("_RadioButton", Model.Bool2})
Thanks all.
@Html.EditorFor(m => m.BoolProperty, "_RadioButton")
and the partial will have@model bool
with@Html.RadioButtonFor(m => m, true, new { @class = "class"})
etc – user3559349