【发布时间】:2018-08-07 09:37:05
【问题描述】:
我可以使用锚标记助手转到不同的剃须刀页面(从现有的剃须刀页面),例如这行得通:
<a asp-page="./EditReport" asp-route-id="@report.IntegrityReportId" class="btn fa fa-edit"></a>
我怎样才能让类似的东西工作,但使用一个按钮。我试过了:
<button type="button" asp-route-data="@report.IntegrityReportId" asp-route="EditReport">EditReport</button>
但是页面永远不会加载。我还尝试使用具有不同变体的页面处理程序:
<input type="button" asp-page-handler="EditReport" asp-route="@report.IntegrityReportId"/>
并关联(在页面cs文件中):
public ActionResult OnEditReport(int id)
{
return RedirectToPage("./EditReport", id);
}
但是这个方法永远不会被调用(我也尝试过命名方法 OnPostEditReport 但同样的问题。
如果有帮助,我原来的非 dotnet 核心应用可以正常工作:
<button type="button" title="Edit report" class="btn btn-datatable fa fa-edit" onclick="location.href = '@Url.Action("EditReport", "Home", new {id = report.IntegrityReportID})'"></button>
任何帮助表示赞赏。谢谢。
【问题讨论】:
标签: asp.net-core asp.net-core-2.0 razor-pages