Right now I am trying to create a link that, upon the user clicking, would change a Boolean without calling up it's own view. Whenever I click the link though, it sends me to a view that doesn't exist. Can anyone find what I'm doing wrong to make sure it stays in the current view and performs the action?
The cshtml:
@Ajax.ActionLink("Hide",
"Hide",
"Manager",
new { id = item.MenuID },
new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "function() { alert('The item has been hidden')"
})
The controller:
[HttpPost]
public ActionResult Hide(int id)
{
Menu menu = db.Menus.Find(id);
if (menu == null)
{
return HttpNotFound();
}
menu.Display = false;
db.Entry(menu).State = EntityState.Modified;
db.SaveChanges();
return new EmptyResult();
}
Also, a slightly related side question, is there a way to make the link into a button?