Erik Funkenbusch
Erik Funkenbusch

Reputation: 93464

Best practices for web application workflow?

Note: By workflow i'm not referring to workflow technology, such as Workflow foundation.

All too often I find myself being required to design pages that flow through a series of steps.

1) Select from a set of options. Submit. 2) Populate a page with results. Make changes. Submit. 3) Do something based on the previous results. Submit. 4) Confirm previous actions. Submit. 5) Goto 1.

An ecommerce site with shopping cart would be a textbook example of this.

Now, there are any number of ways to deal with this. My question is, what is the recommended way to do it in asp.net? In PHP or ISAPI I would just use standard html controls, get the post data and do stuff with it, each on a different page.

ASP.NET seems to be more oriented towards single page solutions. Do your work, postback to yourself, then display your results in the same page.. moving along until the end, using something like a MultiView or UpdatePanels to do the job. But the key being, you don't postback to another page.

Now I understand that Microsoft has added cross-page postbacks to .NET in recent versions, but this seemss less baked and kind of cumbersome. It's difficult to work with data that was posted back unless you expose it via properties or something from your previous page.

How do you handle the scenario I layed out above? Do you use a multi-view or updatepanel and do it all in one page? Or do you do it in several pages? What is your best practices in this regard? Do you have any specific designs you tend to use? How do you go about structuring the sites workflow?

Upvotes: 11

Views: 1429

Answers (3)

MADCookie
MADCookie

Reputation: 2662

Mystere Man, I read your question as asking how do we do it. For me, I have one word: Context. Keep it in context. I'll explain.

You could build an entire web application from one page if you like. Technically it is possible even though it would be as confusing as all get out. I group my functionality together into logical pieces like "Selecting a Product". I used to make a single page grouping the process "Checking Out", but high discourage that now as my team has had to jump into the process at a specific points like automatically adding products to the shopping cart and then displaying the final page in the check-out process. (think of getting a free download: you don't need shipping information, billing formation or their name). With your numbered list above, if it is all on feature, then I would make it one physical page, but I'd break it into multipages if it turns out that I have to "jump into" the flow. If you make it one page, you need clear boundaries.

I don't use cross-posting. I like to use multiview controllers. For me, it is important to clearly identify what each view needs for it to be active. In my page load event, I have one method call that looks at the querystring or session variables or cookies (these are my state holding containers) and, based on what is set, I make active one view. There is no more code in the page load, instead, I use the view's load event to be my pseudo page load. I code whatever that specific view is supposed to do.

With that approach, I think ASP.NET's MVC pattern is where I should be going.

Upvotes: 0

D.J
D.J

Reputation: 2534

there are a number of ways of doing it (besides multi-view):

1, asp.net dose support action post, goggle Page.Request.Form[item] http://msdn.microsoft.com/en-us/magazine/cc164151.aspx#S3

2, you can save your temp data into database temp table, then when users go through each page all they need to do is reference the temp data ID in database. (Query String)

3, you will also be able to save your temp data as a object in your session, so all your pages in the "work flow" can reference the session, then making manipulation based on it.

after all, they all have pros and cons, it mainly depends on how complex your project requirements are.

Upvotes: 1

DaveB
DaveB

Reputation: 9530

For these kinds of situations, I have used multiple panel controls to hold the various steps of the process. Set the visible property to display the UI for the portion you want the user to see.

You might also want to look at the Wizard Web Server Control which handles the plumbing for navigating between the steps of the process. To get some ideas on how the control works, take a look at The ASP.NET 2.0 Wizard Control.

Upvotes: 1

Related Questions