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

前端 未结 7 1550
故里飘歌
故里飘歌 2020-11-28 21:45

I have a form in ASP.Net and razor.

I need to have two ways of submitting said form: one that goes through the Edit action, and another that goes throug

7条回答
  •  爱一瞬间的悲伤
    2020-11-28 22:21

    If you are working in asp.net with razor, and you want to control multiple submit button event.then this answer will guide you. Lets for example we have two button, one button will redirect us to "PageA.cshtml" and other will redirect us to "PageB.cshtml".

    @{
      if (IsPost)
        {
           if(Request["btn"].Equals("button_A"))
            {
              Response.Redirect("PageA.cshtml");
            }
          if(Request["btn"].Equals("button_B"))
            {
              Response.Redirect("PageB.cshtml");
            }
      }
    }
    
    ; ;

提交回复
热议问题