Reputation: 39
I have a view that shows users in the system, including user's status. I need to add a button for each record, this button should pass the user ID for a function in the controller, and this function should've change the value of user's status so if the status is true then it should be changed to false.
The problem here is the button I've added is not calling the function. I need to know why ...
Controller
[HttpPost]
public async Task<IActionResult> Change(string userid)
{
var user = await _userManager.FindByIdAsync(userid);
user.Status = !user.Status;
await _userManager.UpdateAsync(user);
return View();
}
View
<input type="button" asp-controller="Users" asp-action="Change"
asp-route-userid="@user.Id" value="Activate/De Activate" />
Many thanks
Upvotes: 0
Views: 551
Reputation: 39
I replaced the button with this tag , and i added the tag helpers asp-action and asp-controller, and then i removed the post method type from the controller.. it's worked
Upvotes: 1