这就是我想要做
的我有一排有一个打开按钮的项目,该按钮应该打开一个对话框,其中包含该项目,但我无法正确发布网址。在将此图添加到此问题时,我看到了 stackoverflow 如何弹出一个对话框,而这正是我需要做的。我的问题是我需要 url/controller/action?id= (id being passed in)
但我得到的 url 是/controller/action?/7
或者如果我重写操作我得到/controller/action?/7
如何摆脱斜线或正确发布它?
行动链接
@Html.ActionLink("Open", "AddItems", new { id = item.ID }, new { @id =
"Itemdialog" })
jQuery
$('#dialog').dialog({
autoOpen: false,
width: 400,
resizable: false,
modal: true
});
$('#Itemdialog').on("click", function () {
var url = $(this).attr('href');
$('#dialog').load(url, function () {
$(this).dialog('open');
});
return false;
});
控制器:
public ActionResult AddItems(int id)
{
var TradeItem = from i in db.Items
where i.ID == id
select i;
var results = TItem;
return PartialView("_OpenItem", results); //need to open in dialog
}
看法
@model IEnumerable<Item>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.ID)
</th>
<th>
@Html.DisplayNameFor(model => model.user_id)
</th>
<th>
@Html.DisplayNameFor(model => model.item_name)
</th>
<th>
@Html.DisplayNameFor(model => model.item_description)
</th>
<th>
@Html.DisplayNameFor(model => model.item_code)
</th>
<th>
@Html.DisplayNameFor(model => model.dateAdded)
</th>
<th>
@Html.DisplayNameFor(model => model.catId)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.ID)
</td>
<td>
@Html.DisplayFor(modelItem => item.user_id)
</td>
<td>
@Html.DisplayFor(modelItem => item.item_name)
</td>
<td>
@Html.DisplayFor(modelItem => item.item_description)
</td>
<td>
@Html.DisplayFor(modelItem => item.item_code)
</td>
<td>
@Html.DisplayFor(modelItem => item.dateAdded)
</td>
<td>
@Html.DisplayFor(modelItem => item.catId)
</td>
</tr>
}
</table>
@Html.ActionLink(send to db )