Passing data between partitals Views

Asked

Viewed 33 times

1

I have a huge form, it was broken using partial view, created the following doubt that I could not remedy in google, if these views are all of the same control, as I pass the data of partial view To for partial view B, C, and D? For only when it is all filled I can save it without mistakes I know that viewbag and view data go from control to view, Session between controllers, but I don’t know any that pass between partials views or between views.

Partiialview1

@model Software.Models.Laudo

<style type="text/css">
    .ex {
        margin: 10000px;
    } </style>

 @using (Html.BeginForm("Create", "Laudo"))
{

<div class="panel-heading">
    Preencha os campos abaixo para cadastrar um novo laudo no empreendimento:
</div>
<div class="panel-body">
    <div class="row">

        <div class="form-group">
            <div class="col-lg-6" style="margin-left:15px">
                <div class="row">
                    <div id="EmpreendimentoId" class="form-control">
                        <label>EmpreendimentoId</label>
                        <select class="form-control"></select>
                    </div>
                </div>
            </div>
            <br />
            <br />
            <br />
            <div class="row">
                <div class="col-lg-12">
                    <div class="col-lg-4">
                        <label>Interessado</label>
                        <input id="nome" class="form-control" type="text" name="Nome_Empreendimento" placeholder="Nome do empreendimento" readonly>
                    </div>
                    <div class="col-lg-4">
                        <label>Contrato</label>
                        <input id="contrato" class="form-control" type="text" name="Contrato_Empreendimento" placeholder="Contrato do empreendimento" readonly>
                    </div>
                    <div class="col-lg-4">
                        <label>Ordem de Serviço</label>
                        <input id="ordem" class="form-control" type="text" name="Ordem de Serviço" placeholder="Ordem de serviço" readonly>
                    </div>
                </div>
            </div>
            <br />
            <div class="col-lg-12">
                <div class="row">

                    <div class="form-group">
                        @Html.LabelFor(model => model.NumeroRelatorio, htmlAttributes: new { @class = "control-label col-md-2" })
                        <div id="ex">
                            <div class="col-md-10">

                                @Html.EditorFor(model => model.NumeroRelatorio, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                                @Html.ValidationMessageFor(model => model.NumeroRelatorio, "", new { @class = "text-danger" })
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <br>
    </div>
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">1. Ocupante:</h3>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="panel-body">
            <div class="row">
                <div class="form-group">
                    <div class="col-lg-4">
                        <label>Ocupante</label>
                        @Html.EditorFor(model => model.Ocupante, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.Ocupante, "", new { @class = "text-danger" })
                    </div>
                    <div class="col-lg-4">
                        <label>Atributo Identificador(Id)</label>
                        @Html.EditorFor(model => model.IdOcupante, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.IdOcupante, "", new { @class = "text-danger" })
                    </div>
                    <div class="col-lg-4">
                        <label>Contato</label>
                        @Html.EditorFor(model => model.ContatoOcupante, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.ContatoOcupante, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <br>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">2. Endereço do Imóvel:</h3>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="panel-body">
            <div class="row">
                <div class="form-group">
                    <div class="col-lg-4">
                        <label>Endereço do imóvel</label>
                        @Html.EditorFor(model => model.Endereco, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.Endereco, "", new { @class = "text-danger" })
                    </div>
                    <div class="col-lg-4">
                        <label>Bairro</label>
                        @Html.EditorFor(model => model.Bairro, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.Bairro, "", new { @class = "text-danger" })
                    </div>
                    <div class="col-lg-4">
                        <label>Número</label>
                        @Html.EditorFor(model => model.NumeroResidencia, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.NumeroResidencia, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
            <div class="row">
                <br>
            </div>
            <div class="row">
                <div class="form-group">
                    <div class="col-lg-4">
                        <label>Coordenadas UTM SIRGAS 2000</label>
                        @Html.EditorFor(model => model.Coordenadas, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.Coordenadas, "", new { @class = "text-danger" })
                    </div>
                    <div class="col-lg-4">
                        <label>Município</label>
                        @Html.EditorFor(model => model.Municipio, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras e Numeros " } })
                        @Html.ValidationMessageFor(model => model.Municipio, "", new { @class = "text-danger" })
                    </div>
                    <div class="col-lg-4">
                        <label>UF</label>
                        @Html.EditorFor(model => model.Estado, new { htmlAttributes = new { @class = "form-control", @placeholder = "Letras  " } })
                        @Html.ValidationMessageFor(model => model.Estado, "", new { @class = "text-danger" })
                    </div>
                </div>
            </div>
        </div>

    </div>
    <br />

    <div class="form-group">
        <br />
        <div>
            <a href="#tab_1_2" data-toggle="tab" class="btn btn-success">Seguinte</a>
        </div>
    </div>
</div>
<!-- /.col-lg-6 (nested) -->




       }

Partialview2

@model  Software.Models.Laudo


<div class="panel-heading">
    Preencha os campos abaixo para cadastrar um novo laudo no empreendimento:
</div>
<div class="panel-body">
    <div class="row">
        <div class="form-group">
            <div class="col-lg-6">
                <label>Nome da Construtora</label>
                <input id="nome" class="form-control" type="text" name="nome_empreendimento" value="@Html.ValueFor(n=>n.Empreendimento.Nome_Empreendimento)" readonly>
            </div>
            <div class="col-lg-6">
                <label>Ocupante</label>
                <input class="form-control" type="text" value="@Html.DisplayTextFor(n=>n.Ocupante)" name="ocupante" readonly>
            </div>
        </div>
    </div>
    <div class="row">
        <br>
    </div>
    <div class="col-lg-12">
        <div class="row">
            <div class="col-lg-12">
                <h3 class="page-header">3. Caracaterização da região do Imóvel:</h3>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="panel-body">
            <div class="row">
                <div class="form-group">
                    <div class="col-lg-6">
                        <div class="form-group">
                            <label>Tipo da via</label>
                            @Html.EnumDropDownListFor(model => model.Caracterizacao_Regiao_Residencia.Tipo_Via_Regiao, htmlAttributes: new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.Caracterizacao_Regiao_Residencia.Tipo_Via_Regiao, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="col-lg-6">
                        <div class="form-group">
                            <label>Tipo de pavimentação</label>
                            @Html.EnumDropDownListFor(model => model.Caracterizacao_Regiao_Residencia.Tipo_Pavimentacao_Regiao, htmlAttributes: new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.Caracterizacao_Regiao_Residencia.Tipo_Pavimentacao_Regiao, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="row">
                        <br />
                    </div>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label>Fluxo de veículos</label>
                            @Html.EnumDropDownListFor(model => model.Caracterizacao_Regiao_Residencia.Fluxo_Veiculo_Regiao, htmlAttributes: new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.Caracterizacao_Regiao_Residencia.Fluxo_Veiculo_Regiao, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <!-- col-lg-4 -->
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label>Porte de veículos</label>
                            @Html.EnumDropDownListFor(model => model.Caracterizacao_Regiao_Residencia.Porte_Veiculo_Regiao, htmlAttributes: new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.Caracterizacao_Regiao_Residencia.Porte_Veiculo_Regiao, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <!-- col-lg-4 -->
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label>Topografia</label>
                            @Html.EnumDropDownListFor(model => model.Caracterizacao_Regiao_Residencia.Topografia_Regiao, htmlAttributes: new { @class = "form-control" })
                            @Html.ValidationMessageFor(model => model.Caracterizacao_Regiao_Residencia.Topografia_Regiao, "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <!-- col-lg-4 -->
                </div>
                <!-- form-group -->
            </div>
            <!-- row -->
        </div>
        <!-- panel-body -->
        <br />
        <br />
        <div class="form-group">
            <div>
                <a href="#tab_1_3" data-toggle="tab" class="btn btn-success">Seguinte</a>
                <input type="submit" value="Create" class="btn btn-default" />

            </div>
        </div>

    </div>
    <!-- /.col-lg-6 (nested) -->
</div>

<div class="form-group">
    <div class="col-md-offset-2 col-md-10">

    </div>
</div>

in this case sa partials views work as a form so? if I put a create in the last partial it registers as if it were a single? since everything belongs to a controller only?

1 answer

2


You can use according to the code below by passing the id parameter:

@Html.Action("NomeController", "NomeAction", new { id=1 }) 

Or passing an amount from Viewbag:

@Html.Action("NomeController", "NomeAction", new { id=ViewBag.Id }) 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.