0

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: Image with names omitted 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)

4
  • What is the exact error?? Commented Nov 28, 2016 at 15:06
  • "Can someone tell me why is it doing this?" - what is "this", exactly? Commented Nov 28, 2016 at 15:07
  • @PowerStar I only want to show the table and not repeat the "Software Gestão Pedagógica", "Bem vindo, ProfTeste" Commented Nov 28, 2016 at 15:11
  • You got answer below.:) Commented Nov 28, 2016 at 15:18

2 Answers 2

2

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
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.