What About Workflow and ASPX Forms?
Hi everyone,
I’ve gotten a lot of questions about using aspx forms in workflow, so I wanted to talk about them a bit here and hopefully address some of the questions you have. To prevent boring you to death;), I will try keep this pretty high level and short. I’d recommend reading and understanding my post on forms first, as I'll gloss over some concepts from there. Here we go!
One Form Understanding to Rule Them All
Aspx form solutions are not that different from InfoPath (IP) solutions. IP forms are just special out-of-box aspx pages with an IP UI. Aspx forms are just custom aspx pages with aspx UI. That word “custom” instead of “out-of-box” is really all the difference.
Aspx forms are just one level of abstraction lower, so if you understand how data flows from an IP form into a workflow, then you’ll understand what your aspx page needs to do. So what do you do differently when using aspx instead of IP? Perhaps this would be better illustrated with a couple pictures.
The following diagram shows how data flows from an IP solution into the workflow (swiped this from the my blog series doc;)). Stuff you need to implement is circled in red. Data flows from the form to the host aspx page, which calls a special SharePoint function to talk to the workflow. This aspx page is provided out-of-box, so all you have to implement is the UI (the InfoPath form):

With aspx forms, this flow diagram is exactly the same. As with the IP case, you need to implement the UI (this time using aspx controls instead of IP). But there’s one more step this time: you also need to implement the aspx page code-behind to call the workflow function and redirect (which was already provided for you for the IP case). So in summary, the differences between aspx forms and IP forms are that for aspx forms:
a) You’re using aspx controls instead of an IP controls, and
b) You, the developer, have to implement the page that calls the special SharePoint workflow function and redirect to another page(rather than having this done for you out-of-the-box)
So it’s just one more step for aspx forms, as shown in this diagram:

Ok…So How Do You Implement an Aspx Form?
So enough with the theory, you say. What do I have to do to create an aspx workflow form? Well, hopefully if the theory makes sense, you will see that the two things you need to do are:
1) Create the UI (using aspx controls)
2) Write code in the cs file to call the workflow function and redirect to another page
I won’t go into (1) because it’s just standard aspx page implementation. If you’re familiar with the technology, you can add controls and collect the data in the same way you would any non-workflow page.:) You can do anything you want to the page in terms of behavior and validation that you would ordinarily do.
Item (2) is the only thing that’s really specific to workflow. When the user clicks the submit button, you just need to make one of the calls in the table in the forms post:
Association - SPWorkflowAssociation::CreateListAssociation(… associationData)
Then add the association to list or content type using SPList.AddWorkflowAssociation(association...)
Initiation - SPWorkflowManager.StartWorkflow(association, web, list)
Task - SPWorkflowTask.AlterTask(...)
Modification - SPWorkflowManager.ModifyWorkflow(...)
The data you pass in as parameters for these calls can be collected from the user, or you can use other SharePoint OM functions and page parameters to get this information. After you’re done calling the workflow, you can do whatever you want, such as redirecting to a page of choice.
And that’s itJ. While it may seem complex at first glance, at the heart of it, creating aspx forms is really just a matter creating an aspx form that makes a special workflow call.
That Was Easy…Too Easy…
Now, of course, I’m over-simplifying a bit. Setting this up is not a walk in the park (What's all that code in the Aspx Collect Feedback sample?). There’s still some auxiliary work that needs to be done, such as gathering parameters for the call and making the form data string that’s passed into the function “parse-able” by the workflow (e.g. making a serializable class for the data). And of course, you still need to write the general non-workflow-specific code.
But for any workflow, it’s essentially the same thing every time. People have asked me why there aren’t more aspx samples than Aspx Collect Feedback, and a large part of it is that there’s not much more to show. The workflow calls you make are the same for every workflow; the only difference is the data you collect and how you serialize it into the workflow call. Once you understand the concepts behind them, you can use the sample pages for reference, change the UI, and tweak the code and data binding for your custom form.
In any case, I think the biggest hurdle to get over for aspx workflows is a conceptual one, so if you use aspx pages, just remember: it’s just a normal aspx page with a workflow call; be smooth and be cool.
I hope this helps! Good luck!
-Eilene