If a partial view is based upon a base class, is it possible to check if it is a descendant class and if so, use the descndant class’ properties within the Html helpers (LabelFor, EditorFor etc.)?
@model ProjectX.Models.VehicleModel
<div>
@Html.LabelFor(model => model.Fuel)
@Html.TextBoxFor(model => model.Fuel)
</div>
@{
if (Model is CarModel)
{
CarModel car = (CarModel)Model;
@Html.LabelFor(car => car.Doors)
@Html.TextBoxFor(car => car.Doors)
}
}
Yes its possible; try this …
Model classes
View
Hope this helps.