For given screen shot. I have written the following razor code enter image description here

@using (Html.BeginForm("SaveAll", "Home", FormMethod.Post))
{
@model WebApplication2.Models.PersonViewModel

  for(int i=0; i<@Model.Persons.Count; i++)
    {
       @Html.Partial("View", @Model.Persons[i]);
    }

    <input type="submit" name="SaveAll" value="Save All" /> }

and View is a partial view.

@model WebApplication2.Models.Person
@using (Html.BeginForm("AddPerson", "Home", FormMethod.Post)) 
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
    <h4>Person</h4>
    <hr />
    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
    <div class="form-group">
        @Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.Email, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        @Html.LabelFor(model => model.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
        <div class="col-md-10">
            @Html.EditorFor(model => model.LastName, new { htmlAttributes = new { @class = "form-control" } })
            @Html.ValidationMessageFor(model => model.LastName, "", new { @class = "text-danger" })
        </div>
    </div>

    <div class="form-group">
        <div class="col-md-offset-2 col-md-10">
            <input type="submit" value="Add" class="btn btn-default" />
        </div>
    </div>
</div>
}

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Please see the screen shot enter image description here

Parent and Child forms is not rendering properly Please do the help me on this

Related posts

Recent Viewed