append id to actionlink jquery dialog
This is what I'm looking to do I have a row of items that has an open
button which should open a dialog that has that item inside of it, but I
can't get the url to post correctly. In adding this diagram to this
question I saw how stackoverflow pops up a dialog and that's exactly what
I need to do. My problem is I need the url to be /controller/action?id=
(id being passed in) but the url I get is /controller/action?/7 or if i
rewrite the action I get/controller/action?/7 how to get rid of the slash
or post it correctly?
ActionLink
@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;
});
Controller:
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
}
View
@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 )
No comments:
Post a Comment