I have a model class "UpdateClaim" with a nested class "Audit" in it. Both classes are in separate files.
When I generate a Create view from the "UpdateClaim" model, only the "ClaimNumbers" property under the "UpdateClaim" is creating the HTML field and the properties from the nested "Audit" class don't have an HTML field generated in the CSHTML. I have tried having the 2 classes in the same file, but it's the same result.
public class UpdateClaim
{
[Display(Name = "Claim Numbers")]
public string ClaimNumbers { get; set; }
public Audit ObjAudit { get; set; }
}
public class Audit
{
public string Requestor { get; set; }
public string Approver { get; set; }
public DateTime RequestedOn { get; set; }
public DateTime ApprovedOn { get; set; }
public Audit(string requestor, string approver, DateTime requestedOn, Datetime approvedOn)
{
Requestor = requestor;
Approver = approver;
RequestedOn = requestedOn;
ApprovedOn = approvedOn;
}
}
@model ProcessPro.Models.UpdateClaim
@{
ViewBag.Title = "Trigger";
}
<h2>Trigger</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>UpdateClaim</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.ClaimNumbers, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ClaimNumbers, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ClaimNumbers, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}