簡體   English   中英

mvc中的視圖無法再次呈現html

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

當我第二次嘗試在視圖中呈現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>

那個行動

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);
        }

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) {
            }
        });
    }
}

這個標簽沒有關閉。

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

“/“ 失蹤

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM