我在Razor类库中,提交表单不触发OnPost,代码如下:
OnGet是能正常触发的,表单提交时候也关闭了窗口,但是没有触发OnPost。如果把页面移回主项目就正常了
另外我自己加button,去页面上捕捉onsubmit是可以捕捉到的,但是Modal这边的OnPost一直不行
代码语言:javascript复制@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling
代码语言:javascript复制@page
@using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Modal
@using Microsoft.Extensions.Localization
@using ITDog.Localization
@using ITDog.System.Area.Menu
@inject IStringLocalizer<ITDogResource> L
@model ITDog.System.Pages.Areas.Menu.Pages.EditModalModel
@{
Layout = null;
}
<abp-dynamic-form abp-model="MenuDto" asp-page="/Areas/Menu/Pages/EditModal">
<abp-modal>
<abp-modal-header title="@L["UpdateMenu"].Value"></abp-modal-header>
<abp-modal-body>
<abp-input asp-for="Id" />
<abp-form-content />
</abp-modal-body>
<abp-modal-footer buttons="@(AbpModalButtons.Cancel|AbpModalButtons.Save)"></abp-modal-footer>
</abp-modal>
</abp-dynamic-form>
代码语言:javascript复制public class EditModalModel : ITDogPageModel
{
[HiddenInput]
[BindProperty(SupportsGet = true)]
public int Id { get; set; }
/// <summary>
/// 下拉项
/// </summary>
public List<SelectListItem> Menus { get; set; }
/// <summary>
/// 绑定项
/// </summary>
[BindProperty]
public MenuDto MenuDto { get; set; }
private readonly IMenuApplicationService _menuService;
public EditModalModel(IMenuApplicationService menuService)
{
_menuService = menuService;
}
public async Task OnGetAsync()
{
var model = await _menuService.GetAsync(Id);
MenuDto = ObjectMapper.Map<MenuModel, MenuDto>(model);
var menuLookup = await _menuService.GetListAsync(new Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto() { MaxResultCount = 100, SkipCount = 0 });
Menus = menuLookup.Items.Select(x => new SelectListItem(x.Name, x.Id.ToString())).ToList();
}
public async Task<IActionResult> OnPostAsync()
{
var dto = ObjectMapper.Map<MenuDto, MenuModel>(MenuDto);
await _menuService.UpdateAsync(Id, dto);
return NoContent();
}
}