部分视图不更新剃刀值

时间:2017-11-28 18:47:41

标签: c# asp.net-mvc razor

我有一个主页:

@model List<NovoRelatorioWeb.Controllers.HomeController.Campo>

@{
    ViewBag.Title = "Relatorio";
}

<div id="RelatorioTablet">
    <div class="container">
        <div class="row">
            <div class="col-lg-8">

                <div class="row">
                    <div class="col-sm-12">
                        @if (Model != null)
                        {
                            <span>
                                Relatório ELO > Versão 2.0 > @Model[0].Relatorio
                            </span>
                        }
                    </div>
                </div>

                <hr style="border: 1px solid orangered" />

                <div class="row">

                    <div class="col-sm-2">
                        <br />
                        <input type="button" id="butSalvar" class="form-control" style="background-color:orangered" value="Salvar" />
                    </div>
                </div>
                <hr style="border: 1px solid orangered" />

            </div>
            <div class="col-lg-4">
                <div>
                    @Html.Partial("~/Views/Home/PhonePreview.cshtml", Model)
                </div>
            </div>
        </div>
    </div>

</div>

@section scripts {
    <script src="~/Scripts/relatorio_elo.js" type="text/javascript"></script>

}

它会调用另一个页面:

@model List<NovoRelatorioWeb.Controllers.HomeController.Campo>

@{
    Layout = null;
}

<div>

    <div id="PhonePreview" style="border:1px solid black;font-size:20px;">

        @if (Model != null)
        {
            <div class="container1" style="background-color:orangered;padding-top:5px;padding-bottom:5px;">
                <div class="row" style="text-align:center;width:100%;">
                    <div class="col-sm-12" > 
                        <span style="color:white;">
                            @ViewBag.Relatorio
                        </span>
                    </div>
                </div>
            </div>

            foreach (var campo in Model)
            {
                if (campo.Tipo == "Text")
                {                   
                    @Html.Partial("~/Views/Home/Controles/Text.cshtml", campo)                    
                }

            }
        }
    </div>
</div>

<style>
    input[type=date]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        display: none;
    }
</style>

然后调用

@model NovoRelatorioWeb.Controllers.HomeController.Campo

<div class="1" style="padding-top:5px;padding-bottom:5px;">
    <div class="row">
        <div class="col-sm-5">
            <span style="padding-left:5px;">
                @Model.Nome:
            </span>
        </div>
        <div class="col-sm-7" style="text-align:right;">
            <input type="text" style="width:100%;" />
        </div>
    </div>
</div>

我通过jquery ajax调用控制器

 var urlService = "/Home/Salvar";
    var jsonobj = CriaArrayCampos();
    jsonobj = JSON.stringify(jsonobj)

    $.ajax({
        url: urlService,
        type: 'POST',
        data: jsonobj,
        datatype: 'json',
        contentType: 'application/json',
        beforeSend: function () {

        },
        complete: function () {

        }
    });

这意味着,一个调用局部视图的页面和一个局部视图。 OIk,一切正常,但是当我点击保存按钮时,我调用控制器,控制器返回一个带有对象的列表来更新局部视图(我只更新名称)..但是不要更新..但我用剃须刀制作...我已经测试了,这些值来到局部视图......我怎样才能实现这个目标?

非常感谢!

圣拉斐尔

0 个答案:

没有答案