html - ASP MVC 多个 HTML 开始表单和多个 Controller ?可能的

标签 html asp.net-mvc html.beginform

有没有办法让多个 html 开始表单调用多个 Controller ?

示例:

我在1个 View 上有两个表单A和B,然后表单A调用 Controller C,B调用D,这可以实现吗?如果是这样,我会使用 Ajax 或有什么建议吗?

感谢帮助

最佳答案

表单不需要绑定(bind)到构建其 View 的 Controller 。您可以发布到任何您想要的内容:

@using (Html.BeginForm("SomeAction", "Home"))
{
    I'll post to the Home controller.
}

@using (Html.BeginForm("SomeOtherAction", "Security"))
{
    I'll post to the Security controller.
}

这只是呈现常规形式,因此:

<form action="/Home/SomeAction">
</form>

<form action="/Security/SomeOtherAction">
</form>

这是 ASP.NET MVC 做对而 WebForms 做不到的众多事情之一。如果您尝试发布到 WebForms 世界中的不同 aspx 页面,则不会那么容易。

关于html - ASP MVC 多个 HTML 开始表单和多个 Controller ?可能的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19981208/

相关文章:

javascript - 我需要帮助查找 JavaScript 迷你游戏中的错误(我没有收到三个错误)

javascript - 限制 HTML5 视频 currentTime

jquery - Kendo Dropdownlist 与 json 对象的级联

asp.net - Beginform 不发送 View 模型,也没有到达我的 httppost 方法

asp.net-mvc-3 - @Html.BeginForm 在页面上显示 "System.Web.Mvc.Html.MvcForm"

javascript - 密码确认未被触发

javascript - 如何在jquery中访问iframe dom元素

html - 瓦蒂尔 : How do I find an element where the class of that element and the class of one of its parents identifies it?

c# - 如何从使用布局的 View 更改 html

asp.net - 如何在 Telerik ASP .NET MVC 网格上将 bool 值从真/假转换为是/否