【发布时间】:2014-12-30 11:30:11
【问题描述】:
我尝试使用 jquery 通过单击按钮来显示弹出窗口,该按钮放置在与元素对应的行的每一端。
查看:
<input type="button" id="DetailButton" value="Details" onclick="GetDetails(this);"/>
脚本:
function GetDetails(sender) {
var IdElement = $($(sender).parent().parent()).find('input').val();
$.ajax({
type: 'GET',
url: "/ControllerName/ActionName",
data: encodeURI("IdElement=" + IdElement) ,
success: function (view) {
//How to render a view in popup ?
}
});
}
对话框“DialogDetails”在部分视图中:
<div id="PopUpDetails" >
<table>
<thead>
<tr>
<th colspan="1">Element</th>
</tr>
</thead>
<tbody>
<%
foreach (var Item in Model.List)
{ %>
<tr>
<td>
<%:Html.DisplayFor(model => Item.IdElement) %>
</td>
</tr>
<%} %>
</tbody>
</table>
</div>
控制器:
public ActionResult ActionName(int IdElement)
{
ElementViewModel model = new ElementViewModel ();
return View("DialogDetails", model);
}
【问题讨论】:
标签: jquery asp.net-mvc asp.net-ajax