MVC razor form with multiple different submit buttons?

前端 未结 13 2016
-上瘾入骨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:36

    This is what worked for me.

    formaction="@Url.Action("Edit")"
    

    Snippet :

     
    
    
    
     [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult Edit( Quote quote)
            {
               //code 
           }
     [HttpPost]
            [ValidateAntiForgeryToken]
            public ActionResult PartialEdit(Quote quote)
            {
               //code
            }
    

    Might help some one who wants to have 2 different action methods instead of one method using selectors or using client scripts .

提交回复
热议问题