Source--http://support.microsoft.com/kb/953271
- For custom edit item forms and for custom new item forms
- In the XSL code block, locate the following code.
<xsl:template name="dvt_1"> <xsl:variable name="dvt_StyleName">ListForm</xsl:variable> <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/> <table border="0" width="100%"> <xsl:call-template name="dvt_1.body"> <xsl:with-param name="Rows" select="$Rows"/> </xsl:call-template> </table> </xsl:template>
- Replace the lines of code that you located in step 2a with the following lines of code.
<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>
- Locate the following line of code.
<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
- Paste the following code above the line of code that you located in step 2c.
<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>
Additionally, in the __designer:bind attribute, the first parameter for the ddwrtDataBind function should be "'i'" (insert) for a custom new item form and "'u'" (update) for a custom edit item form.
For example, the code may resemble the following code.<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')}"/>
- Save the form.
- Open the Custom List form.
- Move the cursor to the table cell in the custom form control where you want the attachment to be displayed. Then, right-click the cell, point to Insert, and then click Row Below. A new table row that has two column cells is created.
- Move the cursor to the left table cell of the new row, and then type Attachments.
- Move the cursor to the right-side table cell of the new row, switch to Code view, and then enter the following code.
<SharePoint:AttachmentsField ControlMode="Display" FieldName="Attachments" runat="server" Visible="true"/>
- Save the form.
- In the XSL code block, locate the following code.
- If you make more changes to the page, SharePoint Designer 2007 may automatically add a unique ID to the attachment code that you added. For example, “<tr id="idAttachmentsRow">” is changed to “<tr id="idAttachmentsRow{generate-id}">.”
This process may cause JavaScript errors on the page. If this issue occurs, delete the “{generate-id}” tags that are added automatically. - You may receive the following error message:An unexpected error has occurred
- You receive the following a JavaScript error message:Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
- Right-click the List form Web Part in SharePoint Designer.
- Click Web Part Properties, and then click Layout.
- In the Layout dialog box, click to select Hidden, and then close the Web Part.
No comments:
Post a Comment