【发布时间】:2019-07-01 09:18:18
【问题描述】:
无论我做什么,下面的按钮总是调用控制器的OnGetAsync() 方法,而不是所需的SetEditMode()
控制器/型号代码:
public class DetailsModel : PageModelBase
{
private readonly ICommunicationService communicationService;
public DetailsModel(ICommunicationService communicationService)
{
this.communicationService = communicationService;
}
public bool IsEditMode { get; set; } = false;
public EmployeeProfileData EmployeeProfileData { get; set; }
public async Task OnGetAsync()
{
this.EmployeeProfileData = await this.communicationService.GetEmployeeProfileData();
}
[HttpGet(nameof(SetEditMode))]
public IActionResult SetEditMode()
{
this.IsEditMode = true;
return Page();
}
}
查看代码:
@page
@using Common.Resources
@model PersonalProfile.DetailsModel
@{
ViewData["Title"] = TextResources.Profile;
}
<div class="row no-padding col-md-12">
<h3 class="pl-3 mb-3 text-color-medium float-left">@TextResources.EmployeeProfileData</h3>
@if (!Model.IsEditMode)
{
<div class="d-flex justify-content-start mb-2 mx-2">
<a asp-action="SetEditMode" method="get" class="btn btn-light-green">Edit</a>
</div>
}
</div>
【问题讨论】:
标签: c# asp.net-core asp.net-core-mvc