0
Accordingly this link from another question of mine that ended up generating error where I followed the steps referring to another question, I am experiencing a rather strange error.
I created a partial to make the manipulations in the Phones table of my project. Only that simply it is not rendered in any way... She should appear in views of create and Edit of the student’s data.
I’ll put in the codes I used:
View Create( and that of Edit, which is the same thing)
@model SisGAL.Models.Aluno
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Aluno</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.TipoEnsino, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TipoEnsino, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TipoEnsino, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Nome, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Nome, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Nome, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NomePai, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NomePai, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NomePai, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NomeMae, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NomeMae, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NomeMae, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NomeResponsavel, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NomeResponsavel, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NomeResponsavel, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Endereco, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Endereco, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Endereco, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DataNascimento, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DataNascimento, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DataNascimento, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@if (Model != null && Model.Telefones != null)
{
foreach (var telefone in Model.Telefones)
{
Html.RenderPartial("_PartialTelefone", telefone);
}
}
</div>
<div class="form-group">
@Html.LabelFor(model => model.AnoLetivo, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.AnoLetivo, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.AnoLetivo, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Ano, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Ano, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Ano, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Turma, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Turma, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Turma, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NumeroChamada, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NumeroChamada, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NumeroChamada, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Foto, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Foto, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Foto, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Observacoes, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Observacoes, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.Observacoes, "", 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")
}
Partial of phones
@model SisGAL.Models.Telefone
@{
Layout = null;
}
@using (Html.BeginCollectionItem("Telefones"))
{
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.AlunoId)
@Html.EditorFor(model => model.Numero)
@Html.EnumDropDownListFor(model => model.TipoTelefone)
}
Note: I am using the Begincollectionitem package.
You entered at least one empty phone into the student by Controller?
– Leonel Sanches da Silva
Couldn’t get it in controller why it is not rendered to div. I put it right in my hand, right there in the bank table and I referenced the id student. And yet nothing...
– Érik Thiago