c# - 为什么 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>
}
解决方案
您需要安装 AspNet.Mvc nuget 包。
在 NuGet 包管理器控制台中运行Install-Package Microsoft.AspNet.Mvc
或使用 nuget 包管理器安装它应该可以解决您的问题
推荐阅读
- c# - 为什么这个公式在 31 次循环后会中断?
- python - 如何解决“SSL:CERTIFICATE_VERIFY_FAILED”错误?
- python - 没有名为“kivy.logger”的模块;'kivy' 不是一个包
- python - 从 Vector2 获取 X 和 Y 坐标
- reactjs - 如何将我的 react-redux 应用程序限制为仅在所需数据不可用时发出 API 请求?
- c++ - 从 .txt 文件读取到 C++ 语言的结构中
- c# - RedirectToAction() 方法没有正确发送参数
- java - 从模式生成 JAXB java 类:如何获取自定义 XML 元素名称(保留类名称)
- sql - 在 Databricks SQL 中将字符串转换为日期返回 null
- c# - ASP.NET Core - 在控制器中使用 IServiceProvider