How do you handle multiple submit buttons in ASP.NET MVC Framework?

后端 未结 30 3047
一个人的身影
一个人的身影 2020-11-21 07:16

Is there some easy way to handle multiple submit buttons from the same form? For example:

<% Html.BeginForm(\"MyAction\", \"MyController\", FormMethod.Pos         


        
30条回答
  •  情深已故
    2020-11-21 07:53

    Here is what works best for me:

    
    
    
    
    public ActionResult Practice(MyModel model, string onSave, string onDelete)
    {
        if (onDelete != null)
        {
            // Delete the object
            ...
            return EmptyResult();
        }
    
        // Save the object
        ...
        return EmptyResult();
    }
    

提交回复
热议问题