How to: Implement a SharePoint Workflow with ASP.NET Forms
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
SharePoint workflows use forms to handle interactions with users. SharePoint provides two approaches for implementing custom workflow association and initiation forms, modification forms, status forms, and task forms. One approach, which can be used with any Windows SharePoint Services 3.0 installation, uses ASP.NET forms. The other approach, which is only available with Microsoft Office SharePoint Server 2007, uses InfoPath forms. This topic discusses the first approach.
The following procedure is a high-level description of how to use Visual Studio to create ASP.NET custom workflow task forms. This procedure assumes that you can structure a solution in Visual Studio that can deploy a content type, a custom ASPX page, and a workflow. You can use Visual Studio extensions for Windows SharePoint Services and the Visual Studio workflow project template to help you develop and deploy these items.
To create ASP.NET workflow task forms
Using Visual Studio extensions for Windows SharePoint Services, create a custom content type for workflow tasks that is derived from the Workflow Task content type (0x010801). It must specify the URL of the form that displays the task. The following code is an example of a custom workflow task content type.
<ContentType ID="0x01080100b3629edc2920465085800d1eb262d5ad" Name="My Workflow Task" Group="My Group" Description="My Workflow Task Content Type" Version="0"> <FieldRefs/> <XmlDocuments> <XmlDocument NamespaceURI="https://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url "> <FormsUrl xmlns="https://schemas.microsoft.com/sharepoint/v3/contenttype/forms/url"> <Display>_layouts/MyTaskForm.aspx</Display> </FormsUrl> </XmlDocument> </XmlDocuments> </ContentType>
Associate the workflow with the custom workflow task content type. Use the TaskListContentTypeID attribute to do this. The following code shows an example.
<Workflow Name="My Workflow" Description="Workflow that handles my business process." Id="d2eca905-b799-4ec2-aed6-783ee46337ad" CodeBesideClass="MyWorkflowAssembly.MyWorkflowClass" CodeBesideAssembly="MyWorkflowAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" TaskListContentTypeId="0x01080100b3629edc2920465085800d1eb262d5ad"> <Categories/> <MetaData> <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl> </MetaData> </Workflow>
In Visual Studio, create a new ASP.NET Web form that can be deployed to a SharePoint site with a feature. One method for creating this form is to copy one of the list forms that Visual Studio extensions for Windows SharePoint Services provides from the list definition project template. This file is already populated with content elements from the SharePoint master page. Copy the file and reference a custom code behind file that replaces the SharePoint code behind reference. To deploy the form to the _layouts virtual directory, do the following:
- In your Visual Studio extensions for Windows SharePoint Services project, create a folder named Templates.
- Inside the Templates folder, create a folder named Layouts.
- Inside the Layouts folder, add the Web form. The Web solution package that Visual Studio extensions for Windows SharePoint Services creates will then deploy the form to the _layouts virtual directory.
Write the ASP.NET Web form code behind. It should derive from the Microsoft.SharePoint.WebControls.LayoutsPageBase class. The code should both process the workflow task and allow the user to perform the desired action for the task. The workflow task provides the data in a query string that can be used by the custom ASP.NET Web form. The following code shows an example of data that is provided by the query string.
Request.QueryString["List"]; //the Guid Id of the workflow task list Request.QueryString["ID"]; //the List Item Id of the workflow task Request.QueryString["Source"]; //the URL of the referrer page
The following is more information about creating workflow forms:
- For more information about creating a custom content type, see How to: Create a Custom Content Type with Event Receivers.
- For more information about workflow forms, see Workflow Forms Overview on MSDN.
- For more information about developing ASP.NET-related files using Visual Studio extensions for Windows SharePoint Services, see How to: Perform ASP.NET-Related File Development with Visual Studio extensions for Windows SharePoint Services.
- For more information about InfoPath workflow forms, see InfoPath Forms for Workflows on MSDN.
- For more information about SharePoint workflows, see Developer Introduction to Workflows for Windows SharePoint Services 3.0 and SharePoint Server 2007 on MSDN.
- For more information about using Visual Studio extensions for Windows SharePoint Services, see the Visual Studio 2005 Extensions User Guide.
Retired Content |
---|
This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
To provide feedback, get assistance, or download additional, please visit the SharePoint Guidance Community Web site.
Copyright © 2008 by Microsoft Corporation. All rights reserved.