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

后端 未结 30 2993
一个人的身影
一个人的身影 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:47

    it is short and suite:

    It was answered by Jeroen Dop

    
    
    

    and do like this in code behinde

     if( Request.Form["submitbutton1"] != null)
    {
        // Code for function 1
    }
    else if(Request.Form["submitButton2"] != null )
    {
           // code for function 2
    }
    

    Good luck.

提交回复
热议问题