gpt4 book ai didi

asp.net-mvc - 表单提交不提交部分 View

转载 作者:行者123 更新时间:2023-12-04 06:39:03 26 4
gpt4 key购买 nike

我有一个主页,看起来像:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> 
<%
using (Html.BeginForm("Submit", "Customer", FormMethod.Get))
{ %>
<%Html.RenderPartial("Attributes", "Shared");%>
<%=Html.TextBox("Name") %>
<%=Html.TextBox("Area") %>
<%= Html.SubmitButton("Submit", "Click Submit")%>
<% } %>

相应的 Controller 如下所示:
public ActionResult Submit(FormCollection collection)
{

//Form collection is null.

}

Get 请求 URL 不包含 PartialView 字段。但它包含主页字段。我如何确保部分 View 也被提交?

另外,为什么 FormCollection 为空?

更新:

局部 View 如下所示:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>

<%@ Import Namespace="Cenovus.EquipList.Web" %>

<select id="Attribute1"><option value="-1"> Default</option>

</select>

<select id="Attribute2"><option value="-1"> Default</option>

</select>

最佳答案

您需要在表单元素上使用 name 属性来让它们显示在您的表单值集合中。

关于asp.net-mvc - 表单提交不提交部分 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4503391/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com