首页 > 解决方案 > 为什么 Ajax.BeginFom 不退出?

问题描述

我已经安装了 Microsoft.jQuery.Unobtrusive.Ajax。它说:当前上下文中不存在名称“Ajax”。

控制器类:

 public ActionResult SimpleInterest()
    {
        return View();
    }

和视图:

<fieldset>
<legend>Calculate Simple Interest</legend>
@using (Ajax.BeginForm("SimpleInterest", "Employee", new AjaxOptions { UpdateTargetId = "divInterestDeatils" }))
{
    <div id="divInterestDeatils"></div>
    <ol>
        <li>
            @Html.Label("Amount")
            @Html.TextBox("txtAmount")
        </li>
        <li>
            @Html.Label("Rate")
            @Html.TextBox("txtRate")
        </li>
        <li>
            @Html.Label("Year")
            @Html.TextBox("txtYear")
        </li>
    </ol>
    <button>Calculate</button>
}

标签: c#ajaxasp.net-mvcasp.net-core

解决方案


您需要安装 AspNet.Mvc nuget 包。

在 NuGet 包管理器控制台中运行Install-Package Microsoft.AspNet.Mvc或使用 nuget 包管理器安装它应该可以解决您的问题


推荐阅读