I have created a link for deletion in asp.net mvc3 razor view like this:
<td>
@Html.ActionLink("Edit", "EditCategory", new { id = item.CategoryId }) |
@Html.ActionLink("Details", "Details", new { id = item.CategoryId }) |
@using (Html.BeginForm("Delete", "Admin"))
{
@Html.Hidden("id", item.CategoryId)
<input type="submit" value="Delete" />
}
</td>
and created an action method like this:
[HttpPost]
public ActionResult Delete(int Id)
{
Category category = repository.Categories().FirstOrDefault(c => c.CategoryId == Id);
if (category != null)
{
repository.DeleteCategory(category);
TempData["message"] = string.Format("{0} was deleted", category.CategoryName);
}
return RedirectToAction("Categories");
}
It works fine. but I want to use hyperlink for delete as I am using for edit and details. How can I replace the button with actuionlink. I tried that but it is not going in delete post action link and I am getting view not found error.