Task form is displayed using WrkTaskIP.aspx page from TEMPLATE\LAYOUTS folder.
- Create copy of WrkTaskIP.aspx into your project named CustomWrkTaskIP.aspx.
- Register forms.css style:
<asp:Content ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
<SharePoint:CssRegistration runat="server" Name="forms.css" EnableCssTheming="true" />
</asp:Content> - Add the following code into page:
<div>
<h3>Related item</h3>
<table width="100%" class="ms-formtable" border="0" cellspacing="0" cellpadding="0">
<SharePoint:ListFieldIterator ID="ItemFieldIterator" runat="server" ControlMode="Display" />
</table>
</div> - Add codebehind to your page:
public class CustomWrkTaskPage : WrkTaskIPPage
{
protected ListFieldIterator ItemFieldIterator;
protected override void OnLoad(EventArgs ea)
{
base.OnLoad(ea);
Guid workflowInstanceId = new Guid((string)m_task[SPBuiltInFieldId.WorkflowInstanceID]);
SPWorkflow workflow = new SPWorkflow(Web, workflowInstanceId);
ItemFieldIterator.ListId = workflow.ParentList.ID;
ItemFieldIterator.ItemId = workflow.ParentItem.ID;
}
} - Set DisplayFormUrl and EditFormUrl properties of all task content types to your CustomWrkTaskIP.aspx:
foreach (SPContentType taskContentType in taskList.ContentTypes)
{
if (!taskContentType.Id.IsChildOf(SPBuiltInContentTypeId.WorkflowTask))
continue;
taskContentType.DisplayFormUrl = "_layouts/My/CustomWrkTaskIP.aspx";
taskContentType.EditFormUrl = "_layouts/My/CustomWrkTaskIP.aspx";
taskContentType.Update();
}
No comments:
Post a Comment