Note that there are some explanatory texts on larger screens.

plurals
  1. POSubmit multiple buttons on same view
    primarykey
    data
    text
    <p>I need to have multiple buttons on same view, but for some reason it doesn't work. I did already looked at the same questions but I haven't got a solution.</p> <p>How do I know which button is performed in the view?</p> <p>View:</p> <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;LIASWeb.Models.Publication&gt;" %&gt; &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;h2&gt;NewPublication&lt;/h2&gt; &lt;% using (Html.BeginForm()) { %&gt; &lt;div&gt; &lt;fieldset&gt; &lt;p&gt; &lt;label for="Name"&gt;Naam:&lt;/label&gt; &lt;%: Html.TextBoxFor(m =&gt; Model.nmPublication) %&gt; &lt;/p&gt; &lt;p&gt; &lt;%: Html.TextBox("Search", "type naam")%&gt; &lt;input type="submit" name="btnSearch" value="Zoeken" /&gt; &lt;/p&gt; &lt;p&gt; &lt;input type="submit" name="btnSave" value="Opslaan" /&gt; &lt;/p&gt; &lt;/fieldset&gt; &lt;/div&gt; &lt;% } %&gt; &lt;/asp:Content&gt; </code></pre> <p>Controller:</p> <pre><code>public class PublicationController : Controller { private Repository repository = null; public PublicationController() { repository = new Repository(); } public ActionResult NewPublication(String button) { if (button == "btnSave") // perform save action if (button == "btnSearch") // perform save action return View(); } public ActionResult Index() { IEnumerable&lt;Publication&gt; model = repository.Publications; return View(model); </code></pre> <p>}</p> <p>Routings:</p> <pre><code>public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Publication", action = "Index", id = UrlParameter.Optional } ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload