C# ASP MVC绑定IList部分视图问题
我正在尝试使用HTML表单向服务器提交潜在客户信息。首先,我有一个主视图,其中包含一个ajax表单,它决定了我们要提交多少客户。提交后,它将用所需的输入量填充局部视图。两位客户标题的HTML提取示例:C# ASP MVC绑定IList部分视图问题,c#,html,asp.net-mvc,model-binding,C#,Html,Asp.net Mvc,Model Binding,我正在尝试使用HTML表单向服务器提交潜在客户信息。首先,我有一个主视图,其中包含一个ajax表单,它决定了我们要提交多少客户。提交后,它将用所需的输入量填充局部视图。两位客户标题的HTML提取示例: <td class="quoteStandardCell"><input name="sessionPriv.indi[0].title" tabindex="1" class="visualfilesinputtext" id="sessionPriv_indi_0__titl
<td class="quoteStandardCell"><input name="sessionPriv.indi[0].title" tabindex="1" class="visualfilesinputtext" id="sessionPriv_indi_0__title" autofocus="autofocus" type="text" value=""></td>
<td class="quoteStandardCell"><input name="sessionPriv.indi[1].title" tabindex="11" class="visualfilesinputtext" id="sessionPriv_indi_1__title" autofocus="autofocus" type="text" value=""></td>
我想补充一点意见,但我还不能 你们看过浏览器中的web开发者控制台了吗?此数组是否正确地传递给请求
什么是
VisualFileSession
?看起来我需要提高我的调试技能lol。我使用了开发人员控制台,它正在通过。我将断点移动到代码中没有直接操作的位置,它就在那里。似乎我稍后会失去它(我的控制器打电话给经纪人,这(我猜)是导致问题的原因)。
<%using (Ajax.BeginForm("indiView", "Visualfiles", null, new AjaxOptions { UpdateTargetId = "indiPartial", HttpMethod = "post", OnSuccess = "pageLoaded()" }, new { id = "genIndiForm" }))
{ %>
<table class="visualfilestable" id="indiHeadTable">
<tr>
<td colspan="4" class="quoteIndiHeader">Prospect Details</td>
</tr>
<tr class="quoteIndi quoteHeader">
<td class="quoteStandardCell">Prospect Type</td>
<td class="quoteStandardCell"><%: Html.DropDownListFor(n => Model.sessionPriv.type, new SelectList(privateType.types, "typeID", "typeName"), new { @class = "visualfilesinputdropdown", @onchange = "showIndiCount(this.value)", @id = "privateType" }) %></td>
<td class="quoteStandardCell IndiCountTR">Number of Individuals</td>
<td class="quoteStandardCell IndiCountTR"><%: Html.TextBoxFor(n => Model.sessionPriv.indiCount, new { @class = "visualfilesinputtext", @autofocus = "autofocus", type = "number", min = "2", max = "10", id = "indiCount" })%></td>
<td><input class="visualfilespostbutton" type="submit" id="Submitbutton" value="Continue" onclick="document.getElementById('visualfilesbusy').style.display = 'inline';" /></td>
</tr>
</table>
<%} %>
<%using (Html.BeginForm("createPrivate", "Visualfiles", FormMethod.Post, new { id = "createPrivForm", name = "privForm" }))
{ %>
<div class="indiPartial" id="indiPartial"></div>
<% } %>
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<ASPOnline.Models.VisualfilesSession>" %>
<div class="indiWrapper">
<%if (Model != null)
{ %>
<% for (var i = 0; i < Model.sessionPriv.indiCount; i++)
{ %>
<div class="indiDiv">
<table class="indiTable">
<tr class="quoteIndiHeader">
<td colspan="8">Individual <%= i+1 %></td>
</tr>
<tr class="quoteIndi">
<td class="quoteStandardCell">Title</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].title, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 1.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">House Name / Flat</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].houseName, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 4.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">Locality</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].locality, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 7.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">Postcode</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].postcode, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 10.ToString()).AsInt() })%></td>
</tr>
<tr class="quoteIndi">
<td class="quoteStandardCell">Given Name</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].givenName, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 2.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">House Number</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].houseNumber, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 5.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">Town</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].town, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 8.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">Daytime Contact</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].daytimeContact, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 10.ToString()).AsInt() })%></td>
</tr>
<tr class="quoteIndi">
<td class="quoteStandardCell">Family Name</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].familyName, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 3.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">Street Name</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].street, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 6.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">County</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].county, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 9.ToString()).AsInt() })%></td>
<td class="quoteStandardCell">Mobile Number</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].mobile, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 10.ToString()).AsInt() })%></td>
</tr>
<tr class="quoteIndi">
<td class="quoteStandardCell">Email</td>
<td class="quoteStandardCell"><%: Html.TextBoxFor(n => Model.sessionPriv.indi[i].email, new { @class = "visualfilesinputtext", @autofocus = "autofocus", tabindex=(i.ToString() + 10.ToString()).AsInt() })%></td>
</tr>
</table>
</div>
<% } %>
<div class="indiPartialSubmit"><input class="visualfilespostbutton" type="submit" value="Create Private" /></div>
<% } %>
</div>
public class individual
{
// Name
public string title { get; set; }
public string givenName { get; set; }
public string familyName { get; set; }
// Address Details
public string houseName { get; set; }
public string houseNumber { get; set; }
public string street { get; set; }
public string locality { get; set; }
public string town { get; set; }
public string county { get; set; }
public string postcode { get; set; }
// Contact Details
public string daytimeContact { get; set; }
public string mobile { get; set; }
public string email { get; set; }
public individual() {
title = "";
givenName = "";
familyName = "";
houseName = "";
street = "";
locality = "";
town = "";
county = "";
postcode = "";
daytimeContact = "";
mobile = "";
email = "";
}
}
public class priv
{
public int type { get; set; } // Individual/Couple/Group
public int indiCount { get; set; }
public string role { get; set; }
public IList<individual> indi { get; set; }
public priv()
{
type = 0;
indiCount = 0;
role = "";
}
}
[HttpPost]
public ActionResult createPrivate(VisualfilesSession viewSession)
{
return PartialView(getNextPage(viewSession, "createPrivate"), savedSession);
}