views:

24

answers:

1

I have a form like this:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<% using (Html.BeginForm("Edit", "Order", FormMethod.Post, new{id="EditForm"})) 
{%>
<input type="hidden" id="ButtonAction" name="ButtonAction" />
  <div id="orderbuttons">
    <div id="previous">
      <input type="image" name="BtnImage" value="Previous" src="previous.gif" />
      <input type="image" name="BtnImage" value="Save" src="save.gif" />
      <input type="image" name="BtnImage" value="Next" src="next.gif" />
    </div>
  </div>
<% } %>
</asp:Content>

My corresponding action is similar to:

    public ActionResult Edit(OrderModel model, string BtnImage)
    {
        switch (BtnImage)
        {
            case "Previous":
                break;
            case "Save":
                break;
            case "Next":
                break;
        }

        return View(model);
    }

The net effect is that this feels like I have a single action that is comprised of 3 actions. Can anyone suggest what I might change to make improve this?

+2  A: 

Just have a function for each case and call those functions in the ActionResult method. Then ActionResult becomes a simple dispatcher rather than comprising three actions by itself.

Thom Smith