多个表单通过RenderAction提交

| 我正在使用“ 0”在我的视图中包括以下表格:
<%@ Control Language=\"C#\" Inherits=\"System.Web.Mvc.ViewUserControl<IEnumerable<SelectListItem>>\" %>
<% using (Html.BeginForm(\"form1\", \"UserControls\", FormMethod.Post, new { @id = \"form1\" }))
{ %>
<div id=\"superDiv\">Super User | Account:  <%= Html.DropDownList(\"dropdown\", Model)%>
   <button type=\"submit\" class=\"button\">Button</button>
</div>
<% } %>
问题是当我在视图中有一个表单时,例如:
<% using (Html.BeginForm(\"Reports\", \"Report\", FormMethod.Post, new { @id = \"reportForm\", style= \"display:none\" }))
   { %>
   <%: Html.AntiForgeryToken()%>

  <%: Html.Hidden(\"reportType\", null, new { @id = \"reportType\" }) %>
    <div class=\"middle\"><button type=\"submit\" class=\"button\">Generate Report</button>
<% } %>
它将自动从ѭ0submit提交表格,如何防止这种情况?     
已邀请:
也许您应该使用
Partial
而不是
RenderAction
我用它来处理一页上的两种形式(带有2个提交按钮): 第一视图
@using (Html.BeginForm(\"LogOn\", \"Account\", FormMethod.Post)){...}
第二视图
@using (Html.BeginForm(\"Register\", \"Account\", FormMethod.Post)) {...}
第三主视图:
<div style=\"...\">
<div>
    @Html.Partial(\"Login\")
</div>
<div>
    @Html.Partial(\"Register\")
</div>
更新: 我需要将数据加载到用户控件中,并在多个视图/控件上使用它。局部如何工作? 您可以创建“ 9”来接受您的数据/参数并通过局部视图进行渲染
public static MvcHtmlString MyRegisterUserControl(this HtmlHelper html, SomeClass data)
    {
        //maybe some calculations here
        return html.Partial(\"Register\", data);
    }
然后您可以在自己的视图中使用它(类似这样):
@Html.MyRegisterUserControl(new SomeClass(){...});
    

要回复问题请先登录注册