MVC razor form with multiple different submit buttons?

前端 未结 13 1989
-上瘾入骨i
-上瘾入骨i 2020-12-04 12:59

A Razor view has 3 buttons inside a form. All button\'s actions will need form values which are basically values coming input fields.

Every time I click any of butto

13条回答
  •  感情败类
    2020-12-04 13:40

    Simplest way is to use the html5 FormAction and FormMethod

    
        
        
    
    [HttpPost]
    public ActionResult Save(CustomerViewModel model) {...}
    
    [HttpPost]
    public ActionResult SaveForLatter(CustomerViewModel model){...}
    
    [HttpPost]
    public ActionResult SaveAndPublish(CustomerViewModel model){...}
    

    There are many other ways which we can use, see this article ASP.Net MVC multiple submit button use in different ways

提交回复
热议问题