Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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:AttachmentUpload><br/>
  <SharePoint:AttachmentsField  ControlMode="new" FieldName="Attachments" runat="server" Visible="true"><br/>
  </SharePoint:AttachmentsField>

Is there any other way doing this?

share|improve this question
add comment

3 Answers

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.

share|improve this answer
add comment

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"/>

    <div>

            <span id="part1">

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

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

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

                            </xsl:call-template>

            </table>

            </span>

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

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

            </div>

</xsl:template>

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>
<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')}"/>
                   <script>
var elm = document.getElementById("idAttachmentsTable");
if (elm == null || elm.rows.length == 0)
      document.getElementById("idAttachmentsRow").style.display='none';
                  </script> </td>
     </tr>

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 *#

share|improve this answer
add comment

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.

share|improve this answer
    
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.