Posting form to different MVC post action depending on the clicked submit button

后端 未结 4 993
南方客
南方客 2020-12-07 16:23

I am using ASP.Net MVC 4. I have multiple buttons on a view.. At present I am calling the same action method; and I am distinguishing the clicked button using a

4条回答
  •  借酒劲吻你
    2020-12-07 16:57

    BEST ANSWER 1:

    ActionNameSelectorAttribute mentioned in

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

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

    http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-mvc-framework-part-4-handling-form-edit-and-post-scenarios.aspx

    ANSWER 2

    Reference: dotnet-tricks - Handling multiple submit buttons on the same form - MVC Razor

    Second Approach

    Adding a new Form for handling Cancel button click. Now, on Cancel button click we will post the second form and will redirect to the home page.

    Third Approach: Client Script

    
    
    

提交回复
热议问题