As most of you probably know, once you customize a form and use DataFormWebPart you lose the attachments functionality.

After spending several hours investigating this subject, I've installed Hotfix 953749 and successfully managed to display the attached file in EditForm.aspx with DataFormWebPart.

However, I'm still having a problem displaying an AttachmentUpload field in NewForm.aspx (which should let my users the option to add an attachment when creating a new item)

I've tried the following tags in NewForm.aspx, yet the field is not visible.

<SharePoint:FieldLabel ControlMode="New" FieldName="Attachments" runat="server"/><br/>
<SharePoint:FormField runat="server" id="AttachmentsField{$Pos}" ControlMode="New" FieldName="Attachments" __designer:bind="{ddwrt:DataBind('i',concat('AttachmentsField',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"/><br/>

And also:

  <SharePoint:AttachmentUpload ControlMode="new" runat="server" ID="fileupload{$Pos}"><br/>
  <SharePoint:AttachmentsField  ControlMode="new" FieldName="Attachments" runat="server" Visible="true"><br/>

Is there any other way doing this?


I've discovered that you can upload files to Blog template with the following method:

  1. Enable lists attachments in Advanced Settings
  2. Create a custom field type that renders a FileUpload Control.
  3. Add a field of this type to the Posts list. (List settings -> Add Column...)
  4. When creating a new item, the option to select a file will be given.
  5. Click on the Browse button and select a file.
  6. Press OK to submit the form.

Voila! Check item's attachments you'll see that the file you selected before has been uploaded.


Apply the hotfix 953749 of WSS3.0

on code of form change the tag xsl named dvt_1 for this

<xsl:template name="dvt_1">

    <xsl:variable name="dvt_StyleName">ListForm</xsl:variable>

    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>


            <span id="part1">

            <table border="0" width="100%">

                            <xsl:call-template name="dvt_1.body">

                                            <xsl:with-param name="Rows" select="$Rows"/>




            <SharePoint:AttachmentUpload runat="server" ControlMode="Edit"/>

            <SharePoint:ItemHiddenVersion runat="server" ControlMode="Edit"/>



before the tag

<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1" />

write the code:

<tr id="idAttachmentsRow">
 <td nowrap="true" valign="top" class="ms-formlabel" width="20%">
   <SharePoint:FieldLabel ControlMode="Edit" FieldName="Attachments" runat="server"/>
<td valign="top" class="ms-formbody" width="80%">
 <SharePoint:FormField runat="server" id="AttachmentsField" ControlMode="Edit" FieldName="Attachments" __designer:bind="{ddwrt:DataBind('u','AttachmentsField','Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Attachments')}"/>
var elm = document.getElementById("idAttachmentsTable");
if (elm == null || elm.rows.length == 0)
                  </script> </td>

Note: On the ControlMode of code change the correct Mode for Insert or Update for New and Edit respectivily. For Bind Parameters "ddwrt:DataBind(''" replace 'u' for 'i' by the Insert Forms.

Have a nice Code... #/* :D *#


I don't know how to do this, but I have a lot of bad experience using Attachments. We typically find attachments a bad idea because the documents are not easily used by most people. They are hard to find and they can't be assigned any metadata. A better approach seems to be uploading the file to a separate document library and then adding a link to the file when necessary. This allows people to take advantage of the powerful document managment capabilities such as checkin/out, versioning, etc.

  • I think also that at least in WSS 3 that file attachments are not indexed and cannot be searched like they could if in a document library. – spevilgenius Mar 20 '10 at 10:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy