我想将选定的单元格值传递@Html.DisplayFor(model => item.year)
给Url.Action
我在 javascript 中创建的单元格值。
我的控制器有两个参数,一个是静态名称,另一个是从所选行动态获取的年份。
表代码:
<table id="name" border=1 width="50%">
<tr>
<th>Name</th>
<th>Year</th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
<button id="see">@Html.DisplayFor(model => item.year)</button>
</td>
</tr>
}
</table>
javascript代码:
<script type="text/javascript">
var urls = {
view: '@Html.Raw(@Url.Action("(actionName)", "(controller)", new { name = "Mary", year = (this is what idk)}))'
};
$document.ready(function()
{
$('#see').click(function () {
$('#dialog').load(urls.view, function () {
});
});
});
</script>
控制器方法:
public ActionResult actionName(string name, string year)
{
var query = new aquery();
var response = query.Fetch(name, year);
return View(response);
}
调用具有
<form id="", action="@html.raw(@url.action(same thing here as my previous main page. what do i put for the year here now?))">