我正在尝试将下拉菜单的选定值传递给局部视图。
这是称为
的ActionResultpublic ActionResult AddContact(int customerId = 0)
{
ContactModel contact = new ContactModel();
contact.CustomerId = customerId;
return PartialView(contact);
}
这是包含所需值的下拉菜单
@Html.DropDownListFor(model => model.CustomerId, new SelectList(Model.CustomerOptions, "Key", "Value", Model.CustomerId), new { @id = "category", @name = "category", @class = "select-search" })
这是我们需要参数的模态弹出窗口
<div id="modal_form_horizontal_addcontact" class="modal fade">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header bg-success">
<button type="button" class="close" data-dismiss="modal">×</button>
<h5 class="modal-title">Add New Contact</h5>
</div>
<div class="form-horizontal">
<div class="modal-body">
@{Html.RenderAction("AddContact", "Ticket", new { CustomerId = Model.CustomerId });}
</div>
</div>
</div>
</div>
</div>
基本上,模式弹出窗口会为在下拉菜单中选择的客户创建一个新联系人。我需要客户ID才能将联系人添加到该地址。