【发布时间】:2021-07-15 12:58:55
【问题描述】:
我有一个用户应该填写的表格。我希望用户在提交表单之前添加所有者列表。例如,用户输入第一个所有者详细信息并单击添加另一个所有者按钮,然后将提示用户输入其他所有者详细信息等。当用户添加所有所有者时,他可以提交表单。请有任何想法我该怎么做。
我的观点:
@using (Html.BeginForm(Html.BeginForm("SubminWebSiteLicense", "Licenses", FormMethod.Post, new { enctype = "multipart/form-data" })))
{
<div class="row">
<div class="col-md-6">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.WebsiteLink, "WebsiteLink ", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.WebsiteLink, new { @class = "form-control " })
@Html.ValidationMessageFor(model => model.WebsiteLink, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-md-6">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.ApplicationLink, "ApplicationLink", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.ApplicationLink, new { @class = "form-control " })
@Html.ValidationMessageFor(model => model.ApplicationLink, "", new { @class = "text-danger" })
</div>
</div>
</div>
<br />
<h3>OwnersInfo</h3>
<div class="row">
<div class="col-md-4">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.First_Name, "First_Name", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.First_Name, new { @class = "form-control ", @id = "First_Name" })
@Html.ValidationMessageFor(model => model.First_Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-md-4">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.Second_Name, "Second_Name", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.Second_Name, new { @class = "form-control ", @id = "Second_Name" })
@Html.ValidationMessageFor(model => model.Second_Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-md-4">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.Third_Name, "Third_Name", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.Third_Name, new { @class = "form-control ", @id = "Third_Name" })
@Html.ValidationMessageFor(model => model.Third_Name, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.Last_Name, "Last_Name", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.Last_Name, new { @class = "form-control ", @id = "Last_Name" })
@Html.ValidationMessageFor(model => model.Last_Name, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-md-4">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.OwnerNid, "OwnerNid", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.OwnerNid, new { @class = "form-control ", @id = "OwnerNid" })
@Html.ValidationMessageFor(model => model.OwnerNid, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-md-4">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.OwnerMobile, "OwnerMobile", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.OwnerMobile, new { @class = "form-control ", @id = "OwnerMobile" })
@Html.ValidationMessageFor(model => model.OwnerMobile, "", new { @class = "text-danger" })
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="main-form-group main-form-input">
@Html.LabelFor(model => model.OwneEmail, "OwneEmail", new { @class = "control-label main-lable" })
@Html.TextBoxFor(model => model.OwneEmail, new { @class = "form-control ", @id = "OwneEmail" })
@Html.ValidationMessageFor(model => model.OwneEmail, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-md-4">
<br /> <br />
<input type="button" value=" add another owner " class="main-submit" id="AddOwner" name="AddOwner" />
</div>
</div>
<div class="main-form-submit">
<input type="submit" value="submit" class="main-submit" id="submit" name="submit" />
</div>
}
我的主要模特:
public class WebsiteLicenseViewModel
{
public string WebsiteName { get; set; }
public string WebsiteLink { get; set; }
public string ApplicationLink { get; set; }
public string CrNumber { get; set; }
public string OwnerNid { get; set; }
public string OwnerMobile { get; set; }
public string OwneEmail { get; set; }
public string First_Name { get; set; }
public string Second_Name { get; set; }
public string Third_Name { get; set; }
public string Last_Name { get; set; }
public string AttachmentUrl { get; set; }
public List<OwnersViewModel> OwnersList { get; set; }
}
我的 OwnersViewModel:
public class OwnersViewModel
{
public string OwnerNid { get; set; }
public string OwnerMobile { get; set; }
public string OwneEmail { get; set; }
public string First_Name { get; set; }
public string Second_Name { get; set; }
public string Third_Name { get; set; }
public string Last_Name { get; set; }
public List<OwnersViewModel> OwnersList { get; set; }
}
【问题讨论】:
标签: javascript c# jquery asp.net asp.net-mvc