c# - 如何将下拉值传递给局部视图
问题描述
我正在尝试将下拉列表的选定值传递给部分视图。
这是被调用的 ActionResult
public 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 才能添加联系人。
解决方案
推荐阅读
- firebase - 在 react native 项目中安装 react-native-firebase/messaging 时出现问题
- python - Plotly Express:在动画中使颜色条静态化
- google-earth - 使用 Google Earth Enigne 计算无云天数 - Sentinel-5p
- python - 如何优化查IP地址和获取国家?
- javascript - 如何在我的画布标签在我的网页中结束后添加一个部分?
- image - 使用 crypto-js 解密二进制文件(图像)
- jquery - JQuery DataTables 1.8.1 Checkbox - 代码等价
- openssl - 运行 openssl 一次以使用现有私钥和自签名 CA 生成服务器或中间 CA 证书
- r - 不是标准误差的数字 (NaN),下限和上限使用未标记的预测函数
- azure - 使用 openVPN 的容器实例无法正常运行