简体   繁体   English

mvc中的视图无法再次呈现html

[英]view in mvc can not render html for the second time

when I try to render HTML in view for the second time the HTML not change and nothing happens it still as it aims calling the same view two times when the modal is empty and when I fill modal with data and then try to render it this is the view 当我第二次尝试在视图中呈现HTML时,HTML没有改变并且没有任何反应它仍然是因为当模态为空时我将目标调用相同的视图两次并且当我用数据填充模态然后尝试渲染它时这是风景

  <section class="col-12 m-b-60">
    <h2 class="m-b-20">Deduction</h2>
    <form class="form-inline">
        <div class="row">
            <div class="col-6">
                <div class="input-group">
                    <label class="input-text">
                        <span class="label">Employee ID</span>
                        <input type="text" placeholder="Employee ID ..."id="employeid">
                    </label>
                    <a class="btn btn-default" onclick="veiwemployee()">
                        Get
                    </a>
                </div>
            </div>
            <div class="col-6">
                <div class="input-group">
                </div>
            </div>
        </div>
    </form>
</section>
<section class="col-12 m-b-20">
`@if (Model != null)`
    {
      @await Html.PartialAsync("/Views/Home/View.cshtml", Model);
    }
</section>

The action 那个行动

public IActionResult EmployeeDeduction(int employeeID = 0)
        {
            Deduction deduction = new Deduction() ;
            if (employeeID == 0) { }
            else
            {
                ModelState.Clear();
                deduction = _conn.GetEmployeByEmployeeID(employeeID);
            }
            return View("/Views/view.cshtml",deduction);
        }

The Js function Js功能

function veiwemployee() {
    if ($("#employeid").val() == "") {
        $("#employeid").style.borderColor = "red";
    }
    else {
        $.ajax({
            type: 'POST',
            url: '/Home/EmployeeDeduction?employeeID=' + $("#employeid").val(),
            async: false,
            dataType: 'json',
            success: function (resp) {
            }
        });
    }
}

this tag does not have closing. 这个标签没有关闭。

    <input type="text" placeholder="Employee ID ..." id="employeid">

"/" missing “/“ 失踪

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM