SIGN UP MEMBER LOGIN:    
ARTICLE

Enable Attachment in SharePoint Blog post list and display the list Attachments

Posted by Suri meenakshi Sundaram Articles | SharePoint October 25, 2010
In this article you will learn how to Enable Attachment in SharePoint Blog post list and display the list Attachments.
Reader Level:

Generally, SharePoint blog site, Post list doesn't have attachment facility to add documents to the list.

Here we will see, how we can handle it in different ways.

Approach 1: we handle it in site definition level.

Go the following location to Enable Attachments:

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\SiteTemplates\Blog\Lists\Posts\schema.xml

Open the Schema.xml

Change from

<Forms>
<Form Type="DisplayForm" Url="ViewPost.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditPost.aspx" ToolbarTemplate="BlogEditFormToolBar" Template="BlogForm" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewPost.aspx" ToolbarTemplate="BlogNewFormToolBar" Template="BlogForm" WebPartZoneID="Main" />
</Forms>

Change to

<Forms>
<
Form Type="DisplayForm" Url="ViewPost.aspx" WebPartZoneID="Main" />
<Form Type="EditForm" Url="EditPost.aspx" WebPartZoneID="Main" />
<Form Type="NewForm" Url="NewPost.aspx" WebPartZoneID="Main" />
</Forms>

Once it is updated then do IIS rest as iisreset /noforce

After Changing, it will be available while adding new item.

image1.gif

Approach 2: we will add the Following Code inside the Default list pages.

Add the following Code into Newpost.aspx and Editpost.aspx page.

Add the Row next to the Webpart zone Row. It will work only with sharepoint default list pages.

Note:- if you using customized form pages, it will not work

<tr>
<
td>
<
div>
<
a title="Attach File" class="ms-toolbar" accessKey="I" onclick="javascript:UploadAttachment();" href="javascript:UploadAttachment()">
<img width="16" height="16" align="absMiddle" style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px;" alt="Attach File" src="/_layouts/images/attachtb.gif" complete="complete"/>
</a>
<
a id="ctl00_m_g_7df5d998_1390_4e67_8fc4_2da066cbcf7d_ctl00_ctl01_ctl00_toolBarTbl_RptControls_diidIOAttach{generate-id()}" style="visibility: hidden;" href="javascript:UploadAttachment()"/>
<a class="ms-toolbar" id="ctl00_m_g_7df5d998_1390_4e67_8fc4_2da066cbcf7d_ctl00_ctl01_ctl00_toolBarTbl_RptControls_diidIOAttach_LinkText" accessKey="I" onclick="javascript:UploadAttachment();" href="javascript:UploadAttachment()">Attach Photo</a>

image2.gif

After Adding this, it will be available as shown below to attach the file to the "Post" list item :

image3.gif


Now Will see how we can display the attachments after uploading into the List item.

First add the following XSL code in the Dataform webpart .

image4.gif

<td > <div id="Imagepath" >
<xsl:element name="SharePoint:AttachmentsField">
<xsl:attribute name="runat">server</xsl:attribute>
<xsl:attribute name="ListId">{2F4DE07B-6268-4544-A172-A02ED31618EE} </xsl:attribute>
<xsl:attribute name="FieldName">Attachments</xsl:attribute>
<xsl:attribute name="ControlMode">Display</xsl:attribute>
<xsl:attribute name="Visible">true</xsl:attribute>
<xsl:attribute name="ItemId"><xsl:value-of select="@ID" /></xsl:attribute>
</xsl:element>
</div></td>

Once you added into that, you will get the filename with path.

Using the file path, we can show this in Image tag wherever we required.

Add the Empty DIV tag to display attachment Image.

<tr><td><div id="AttachmentImage"></div>
</td></tr>

image5.gif


 

Login to add your contents and source code to this article
share this article :
post comment
 

Thank you for the steps. They were useful and solved the doubt to a great extent. But i want the paperclip icon to be displayed in the list and want to know where the atachments are being saved. When I tried, the path is appearing on the screen with the delete button, but on clicking OK, the attachment is not being saved. Is there a way out to solve this issue?

Posted by Srividya Ravi Jan 04, 2012
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Become a Sponsor