Symptoms
When a custom display form is generated by SharePoint Designer the attachment will not be exposed if one is present. Please refer to the following link for additional information in regards to custom list forms:http://office.microsoft.com/en-us/sharepoint-designer-help/create-a-custom-list-form-using-sharepoint-designer-HA010378258.aspx The out of the box ListFormWebPart does not exhibit this behavior.
Cause
The markup required to make this work is missing from the client.
Resolution
To workaround this issue users can create a code snippet and insert the markup as needed via the code view.
Alternatively, users can just paste the markup that is use to create code snippets into the custom list form. The following markup can be used to create the code snippet:<tr>
<td nowrap="true" valign="top" class="ms-formlabel" width="20%"> <SharePoint:FieldLabel ControlMode="Display" FieldName="Attachments" runat="server"/> </td> <td valign="top" class="ms-formbody" width="80%"> <SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="Display" FieldName="Attachments" __designer:bind=""/> </td> </tr>
To create a code snippet in SharePoint Designer 2010 do the following:
1. Click the File menu inside of SPD 2010. 2. Then click Options and under the general tab pick Page Editor Options. 3. Switch to the Code Snippets tab. 4. Click the Add button and give it a name like attachmentFix. 5. Provide a description to help given context to the code snippet. 6. Paste the following markup to automate the task of adding in the attachment functionality for display forms.<tr>
<td nowrap="true" valign="top" class="ms-formlabel" width="20%"> <SharePoint:FieldLabel ControlMode="Display" FieldName="Attachments" runat="server"/> </td> <td valign="top" class="ms-formbody" width="80%"> <SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="Display" FieldName="Attachments" __designer:bind=""/> </td> </tr>
7. Click OK and then OK.http://msdn.microsoft.com/en-us/library/aa218645(v=office.11).aspx#odc_fpcustomizingsnippets_tocreateacodesnippet TheĀ file SnippetsCustom.xml contains the following after performing the steps above:
8. Now, when working with a custom list form and it requires the above markup perform the following in code view: Control + Enter. 9. This will bring up the built in code snippets and the one created. Pick attachmentFix and all the markup will be inserted. This can be further automated through a group policy or other delivery mechanisms. For example, Windows 7 uses the following path to store custom code snippets: C:\Users\UserName\AppData\Roaming\Microsoft\SharePoint Designer\Snippets The following document explains the code snippet's internals:<?xml version="1.0"?>
<!-- Code Snippet Configuration File --> <snippets><snippet keyword="attachmentFix"> <description>Custom display form attachment fix.</description> <text><tr> <td nowrap="true" valign="top" class="ms-formlabel" width="20%"> <SharePoint:FieldLabel ControlMode="Display" FieldName="Attachments" runat="server"/> </td> <td valign="top" class="ms-formbody" width="80%"> <SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="Display" FieldName="Attachments" __designer:bind=""/> </td> </tr></text> </snippet> </snippets>
More Information
The Edit and New Forms don't have this issue depending on your patch level and product version.
1. After installing Service Pack 2 for SharePoint Designer 2007 and WSS 3.0 the attachment functionality will work correctly for Edit and New Forms going forward. Old forms will need to be supplemented with the new functionality. 2. SharePoint Designer 2010 and SharePoint Foundation work correctly with Edit and New forms out of the box. 3. SharePoint Designer 2007 and SharePoint Designer 2010 experience the issue with Display forms.