【发布时间】:2017-04-14 13:51:23
【问题描述】:
在我的MVC 视图中,我正在打开一个模式对话框,它将PartialView 呈现为RenderAction。当用户单击特定行的Add 按钮时,视图将打开,如下所示。
从主视图中,我想传递当前行的(选择行)ProjectNo、DrawingNo 和 RevisionNo。另外,最好我想将其传递到各自的 ViewBag's 字段中。我怎样才能做到这一点?
这是我调用对话框的源代码。
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Enter Fabrication Information</h4>
</div>
<div class="modal-body">
<div>
@{Html.RenderAction("Create", "Fabrication", new BPs.Entities.FABRICATION { });}
</div>
</div>
</div>
</div>
更新:为每一行添加 html
@foreach(var info in @Model)
{
<tr>
<td>info.ProjectNo</td>
<td>info.DrawingNo</td>
<td>info.RevisionNo</td>
<button >Add</button>
</tr>
}
【问题讨论】:
-
这可能会对您有所帮助:stackoverflow.com/questions/37844621/…
-
您需要提供更多信息。每行的 html 是否包含
ProjectNo、DrawingNo等的数据(例如data-*属性)。显示典型行的 html 格式。 -
@StephenMuecke 请查看更新后的问题(我添加了表格的 html 外观示例)
-
假设您处理按钮的
.click()事件,那么var row = $(this).closest (tr);将获得当前行,row.find (td).eq (0).text();将获得第一个单元格的文本。 -
我现在得到了那个部分,但是我如何将它发送到我正在使用 RenderAction 加载的视图?
标签: asp.net asp.net-mvc bootstrap-modal