我刚开始学习 MVC,所以请多多包涵。
我有一个表格,其中有几个选项,您可以编辑、删除和显示详细信息。
如果我现在单击详细信息按钮,它将带我到另一个页面(Details.cshtml) ,该页面与显示上表的Index.cshtml 位于同一控制器中。
这是表格的代码(Index.cshtml)
@model Collusus.Models.IndexModel
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<h2>Hello @Html.ActionLink(Model.userLoggedIN, "getProfile")</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>Change ID</th>
<th>Owner</th>
<th>Priority</th>
<th>Disposition Date</th>
<th>Completion Date</th>
<th>Do what?</th>
</tr>
</thead>
<tbody>
@for(int i=0; i<Model.changes.Count(); i++)
{
<tr>
<td>@Model.changes[i].ID</td>
<td>@Model.changes[i].Owner</td>
<td>@Model.changes[i].Priority</td>
<td>@Model.changes[i].DispositionDate.ToShortDateString()</td>
<td>@Model.changes[i].ActualCompletionDate.ToShortDateString()</td>
<td>@if (Model.changes[i].Owner == Model.userLoggedIN)
{
@Html.ActionLink("Delete", "Delete", new { id=Model.changes[i].ID })
@Html.ActionLink("Edit", "Edit", new { id=Model.changes[i].ID })
}
@Html.ActionLink("Details", "Details", new { id=Model.changes[i].ID })
</td>
</tr>
}
</tbody>
</table>
正如您所看到的,由于下面的代码,它只会将我带到另一个页面。
@Html.ActionLink("Details", "Details", new { id=Model.changes[i].ID })
我想做的事:
- 在对话框而不是另一个页面中打开删除、编辑或详细信息视图。
- 仍然能够像打开另一个页面一样具有相同的功能。
我不知道这是否有太多意义。我试图尽我所能解释它,并且在搜索谷歌/尝试其他解决方案的代码时感到沮丧,但无法让它发挥作用。
如果您建议除了 JQUERY 对话框之外的另一种方式,我也愿意采用该选项。感谢所有帮助,因为我一直很沮丧。