Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Document type field: File selection View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
dion.tsai-adrenalinmedia.com - 10/19/2011 1:43:36 AM
   
Document type field: File selection
Hi there,

I have an issue on getting the file from the field type, File selection.

Below is my code. "Resource" is the file selection field type.


<td><a target="_blank" href="<%#GetFileUrl("Resource")%>"><%# Eval("Title") %></td>


the output of href is like following.

<td><a target="_blank" href="/KenticoCMS/getattachment/a242bfb4-81e8-4309-be3b-493aa8817335/product-resource-1.aspx">product resource 1</a></td>

However, the link is not a valid file link for me. Any ideas?

User avatar
Member
Member
kentico_michal - 10/19/2011 8:25:11 AM
   
RE:Document type field: File selection
Hello,

File selection field stores a NodeGUID of selected document. So, you will need to use GetDocumentUrl method instead of the GetFileUrl method:

<a target="_blank" href="<%# GetDocumentUrl("Resource", "NodeAlias") %>"> <%# Eval("Title") %> </a>


Best regards,
Michal Legen

User avatar
Certified Developer v7
Certified  Developer v7
dion.tsai-adrenalinmedia.com - 10/19/2011 5:59:24 PM
   
RE:Document type field: File selection
Thanks, that works for me. So for GetFileUrl function, what field type do we use them?

User avatar
Member
Member
kentico_michal - 10/20/2011 5:15:59 AM
   
RE:Document type field: File selection
Hello,

The GetFileUrl returns link to a file (Attribute type: File) in the following format:

~/getattachment/<fileGUID>/nodeAlias.aspx

Best regards,
Michal Legen

User avatar
Certified Developer v7
Certified  Developer v7
dion.tsai-adrenalinmedia.com - 10/20/2011 9:19:30 PM
   
RE:Document type field: File selection
Thanks a lot.