我可以使用锚点标签助手从一个现有的razor页面跳转到另一个razor页面,例如:
<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,但是问题依旧)。
如果有帮助的话,我的原始非.NET Core应用程序可以正常工作:
<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>
非常感谢您的帮助。谢谢。