简体   繁体   中英

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

  <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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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