0

Please see the picture.

I have three actions. (Remove the class, Reserve the class and Add more classes)

Can I use one or more multiple form action in cshtml?

Bengi Besçeli
  • 3,638
  • 12
  • 53
  • 87
MayHnin
  • 29
  • 2
  • 2
    Did you google for this? For example: http://stackoverflow.com/questions/442704/how-do-you-handle-multiple-submit-buttons-in-asp-net-mvc-framework – L-Four Feb 13 '17 at 08:43
  • I was about to answer, then I saw this comment from @L-Four :) – Yogi Feb 13 '17 at 08:54
  • Possible duplicate of [How do you handle multiple submit buttons in ASP.NET MVC Framework?](http://stackoverflow.com/questions/442704/how-do-you-handle-multiple-submit-buttons-in-asp-net-mvc-framework) – Yogi Feb 13 '17 at 08:55
  • In this cshtml, I want to pass hiddenfor object. So, write three times hidden for object? – MayHnin Feb 13 '17 at 08:57
  • Yeah go for it. Might want to look at ways for the controller to determine which action should be executed based on the values submitted. – Nico Feb 13 '17 at 09:00

1 Answers1

1

Yes. In order to call them in View:

<input type="button" value="Remove Button Name" onclick="location.href='@Url.Action("ActionName", "ControllerName", new { yourParameterHere= 'ValueOfYourParameter' })'" />

Basically your ActionName would be the name of your Action = "Remove" for example.

Your Parameter name would be the parameter name that you will be receiving in your ActionName for example:

public ActionResult Remove(int intRemoveID) //intRemoveID would be your parametername
    {
        return View();
    }

This should be the same on other buttons as well. Let me know if you need clarifications.

Willy David Jr
  • 8,604
  • 6
  • 46
  • 57