views:

1749

answers:

5

If you had to provide a wizard like form entry experience in mvc how would you abstract the page flow?

Thanks

A: 

There are a couple ways, create an action for each step of the wizard process, or create a parameter that is passed in to the action method. Like step that will allow you to know what the state of the wizard is in.

Nick Berardi
+6  A: 

Investigate the post-redirect-get pattern.

http://weblogs.asp.net/mhawley/archive/tags/MVC/default.aspx
http://devlicio.us/blogs/tim_barcz/archive/2008/08/22/prg-pattern-in-the-asp-net-mvc-framework.aspx

Use that along with a robust domain model (for tracking steps or form completion state or whatever you call it) and you're golden.

Matt Hinze
A: 
public class CreateAccountWizardController : Controller
{
   public ActionRresult Step1()
   {
   }


   public ActionResult Step2()
   {
   }
}
Ben Scheirman
A: 

In order to keep the steps you could implement a page flow action filters, which provide an experience like this one:

[RequiredStep(FlowStart = true)]
public ActionResult Confirm()
{
    return View();
}

[RequiredStep (PreviousStep = "Confirm")]
public ActionResult ExecuteOrder()
{
    return RedirectToAction("ThankYou");
}

[RequiredStep(PreviousStep = "ExecuteOrder")]
public ActionResult ThankYou()
{
    return View();
}
CodeClimber
A: 

I left the page flow up to the view, where I believe it belongs, so different views could have different page flows (e.g. for desktop browser clients or mobile phone clients etc.) I wrote it up on my blog: A RESTful Wizard Using ASP.Net MVC… Perhaps?