button url action code example

Example 1: button action asp net

<input type="button" value="Create" onclick="location.href='@Url.Action("Create", "User")'" />

Example 2: html button with action link

<input type="button" class="btn btn-info" value="Let's Go!" onclick="location.href='@Url.Action("Action", "Controller")'" />

Example 3: To call any action method from the view on button click in mvc

BY LOVE
Here, Action name=Edit, ControllerName=Home.
@using (Html.BeginForm("Edit", "Home", new { Id = emp.Id }, FormMethod.Get))
                            {
                                <button>EDIT</button>
                            }
@using (Html.BeginForm("Delete", "Home", new { Id = emp.Id }, FormMethod.Post))
                            {
                                <button>DELETE</button>
                            }

Tags:

Html Example