Click here to Skip to main content
15,890,946 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My controller Code is as such-
C#
[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 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!
Posted
Updated 30-Sep-13 20:06pm
v2
Comments
Sampath Lokuge 1-Oct-13 2:13am    
Can you put the code which you have used to go to view2's post function ? I mean button's code or like that ?
[no name] 1-Oct-13 2:24am    
Im trying to build a custom wizard.

view1 button-
<input id="NewClientButton" type="submit" value="submit" />

view2 button-
<input value="Accept" id="acceptbtn" type="submit" />

view1,view2 are all using same controller and model..

1 solution

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.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900