ASP.Net MVC 4 Form with 2 submit buttons/actions

前端 未结 7 1502
故里飘歌
故里飘歌 2020-11-28 21:45

I have a form in ASP.Net and razor.

I need to have two ways of submitting said form: one that goes through the Edit action, and another that goes throug

相关标签:
7条回答
  • 2020-11-28 22:40

    <input type="submit" value="Create" name="button"/>
    <input type="submit" value="Reset" name="button" />

    write the following code in Controler.

    [HttpPost]
            public ActionResult Login(string button)
            {
                switch (button)
                {
                    case "Create":
                        return RedirectToAction("Deshboard", "Home");
                        break;
                    case "Reset":
                        return RedirectToAction("Login", "Home");
                        break;
                }
    
                return View();
            }
    
    0 讨论(0)
提交回复
热议问题