views:

877

answers:

2

I have created custom list and modified display form of list for display attached image of list.
I have place HTML image control on display form but I can’t get attachment URL path which I can assign to Image control. I tried to some level hardcode like:

http://Server Name/SiteName/Lists/ListName/Attachments/{@ID}/???

I can get ID value so it can be work but the last thing file name, I am not able to get the attached file name.
Do I need to write code to get path? If yes then which event I have to inherited

+1  A: 

This solution requires undocumented magic.

...puts robe and wizard hat

Inside your table with the @Title and such:

<tr>
    <td width="190px" valign="top" class="ms-formlabel">
     <H3 class="ms-standardheader">
      <nobr>Attachments</nobr>
     </H3>
    </td>
    <td width="400px" valign="top" class="ms-formbody">
      <SharePoint:FormField runat="server" id="attachmentsField" ControlMode="Display" FieldName="Attachments" />
    </td>
</tr>

You can change the attribute ControlMode to "Edit", it shows the Delete option.

F.Aquino
A little explanation, the @Attachments attribute returned by the list items only tells that the list item has one or more attachments, the actual list is a different query, luckily all the hassle is handled by the FormField control
F.Aquino
this solution output the entire link html. i just want the attachment file name.or, how can i control the output of the SharePoint:FormField tag?
kisin
That requires a way more complicate override in the control render, see http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.templatebasedcontrol.customtemplate.aspx
F.Aquino
A: 

well, didnt find any easy and good answer, so i solved it with good old jquery magic.

its a shame that there isnt any easy solution for this....

kisin
but you did use the FormField control?
F.Aquino