Reputation: 107
I have this view to make a menu where I use a @Html.Action:
@model SGP.Models.Turma
@{
ViewBag.Title = "Menu";
}
...
@Html.Action("AvaliacaoLista", "Turma", new { id = Model.TurmaId })
The view in the Html.Action:
@model List<SGP.Models.PessoaModel2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<th>Nome</th>
<th>Numero</th>
@foreach (String s in ViewBag.Componentes)
{
<th>@s</th>
}
<th>Nota Final</th>
</tr>
@for (int i = 0; i < Model.Count; i++)
{
<tr>
@Html.HiddenFor(x => Model[i].turmaId)
@Html.HiddenFor(x => Model[i].userid)
<td>@Model[i].nome</td>
<td>@Model[i].num</td>
@for (int a = 0; a < Model[i].am.Count; a++)
{
@Html.HiddenFor(x => Model[i].am[a].AvaliacaoId)
<td>@Html.DisplayFor(x => Model[i].am[a].nota)</td>
}
<td>@Model[i].notafinal</td>
</tr>
}
</table>
}
This is what it shows in the view:
Can someone tell me why is it doing this? Or should I use other way to make that table appear in the menu instead of using Html.Action?
Thanks
(I only want to show the table and not repeat the header)
Upvotes: 0
Views: 160
Reputation: 20374
Ahh ok I can see what your problem is. You "heading" is repeating itself.
The simplest way to solve this is to add:
@{
Layout = null;
}
To any View that you want to render only the HTML within. This way it will not render layout pages, that are by default, rendered with the views.
Upvotes: 1
Reputation: 12491
You getting your logo twice becouse your View have it also (which you call with Html.Action
) so just set your subView Layout
to null
:
@model List<SGP.Models.PessoaModel2>
@{
Layout = null;
}
// your other stuff
Upvotes: 2