控制器回发的mvc4问题 [英] mvc4 issue with controller postback

查看:83
本文介绍了控制器回发的mvc4问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的控制器代码就是这样 -

My controller Code is as such-

[HttpGet]
      public ActionResult view1()
       {
           return View();
       }
       [HttpPost]
       public ActionResult view1(string NewClientButton)
       {
           return View("view2",NewClientButton);

       }
       [HttpGet]
       public ActionResult view2()
       {
           return View();
       }
       [HttpPost]
       public ActionResult view2(string hasAccept)
       {
            return View("view3");
        }





view1发帖回复...但是当我在view1中并希望进入view2 post fucntion ...代码再次回到view1 post功能...这是我面临的问题...有人可以尝试在这里帮忙!谢谢!



view1 posts back fine...but when im in view1 and expect to go into view2 post fucntion...the code steps back into view1 post function again...which is the problem im facing...can someone please try to help here! Thanks!

推荐答案

尝试如下(这是一个样本)。



Try like below (This is a sample).

@using( Html.BeginForm("view1", "controllerName", new { NewClientButton=Model.NewClientButton},
                       FormMethod.Post, new { @class = "example" } ) )
{
<button id='NewClientButton' name="subject" type="submit" value="submit">Button1</button>
}


@using( Html.BeginForm("view2", "controllerName", new { hasAccept=Model.hasAccept},
                       FormMethod.Post, new { @class = "example" } ) )
{
<button id='acceptbtn' name="subject" type="submit" value="Accept">Button2</button>
}





我希望这会对你有所帮助。



I hope this will help to you.


这篇关于控制器回发的mvc4问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆