Asp.Net - AspPageHandler 不触发按钮
Asp.Net - AspPageHandler does not fire with button
(使用.NET Core 3.1)
我有一个可用的处理程序,但我无法从 <button/>
调用它。从 <a/>
它可以工作(但这会尝试刷新我的页面,但这不是我想要的)。
//GETS TO HANDLER
<a class="btn btn-info" asp-page-handler="SearchProductionRecords">
<i class="fas fa-file-excel mr-2"></i> Export Excel
</a>
//NEVER GETS TO HANDLER
<span class="input-group-append">
<button type="submit" asp-page-handler="SearchProductionRecords" class="btn btn-info btn-sm"><i class="fas fa-search"></i> </button>
</span>
//HANDLER
public async Task<IActionResult> OnPostSearchProductionRecordsAsync()
{
...
}
按钮提交与表单提交关联。因此,将按钮放在表单 method=post 中,它应该可以工作。
亲切的问候,
马赫什瓦拉
(使用.NET Core 3.1)
我有一个可用的处理程序,但我无法从 <button/>
调用它。从 <a/>
它可以工作(但这会尝试刷新我的页面,但这不是我想要的)。
//GETS TO HANDLER
<a class="btn btn-info" asp-page-handler="SearchProductionRecords">
<i class="fas fa-file-excel mr-2"></i> Export Excel
</a>
//NEVER GETS TO HANDLER
<span class="input-group-append">
<button type="submit" asp-page-handler="SearchProductionRecords" class="btn btn-info btn-sm"><i class="fas fa-search"></i> </button>
</span>
//HANDLER
public async Task<IActionResult> OnPostSearchProductionRecordsAsync()
{
...
}
按钮提交与表单提交关联。因此,将按钮放在表单 method=post 中,它应该可以工作。
亲切的问候,
马赫什瓦拉