Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Create Download link in Repeater View modes: 
User avatar
Member
Member
afique-resolvtech - 12/1/2013 11:00:11 PM
   
Create Download link in Repeater
Hi,

Can anyone help me on creating a download link in repeater?

I wanted to create a download link for my PDF file.

I did this but it show me and Error
<a class="header bold" href="<%# GetDocumentUrl("Pdf1") %>">File</a> 

I did the second one, the document appear and I can view the pdf.
<a class="header bold" href="<%# Eval("Pdf1") %>">File</a>

Can anyone help me?

Thanks

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 12/1/2013 11:23:15 PM
   
RE:Create Download link in Repeater
It all depends on the way you are saving that file (PDF1). If you are saving it as a URL then Eval("Pdf1") will work just fine. If you are using an GUID then you need to use another method.

User avatar
Member
Member
afique-resolvtech - 12/1/2013 11:49:45 PM
   
RE:Create Download link in Repeater
Hi ,

I'm using custom table and store all the PDF files using Media File Selection.

If I use Eval, yes definitely the PDF will appear when user click it. But I wanted the document to by downloaded directly when user click it.

Any suggestion?


Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/2/2013 1:37:46 AM
   
RE:Create Download link in Repeater
Hello,

You can simply append following query string to that url:
?disposition=attachment

Best regards,
Jan Hermann

User avatar
Member
Member
afique-resolvtech - 12/2/2013 2:46:49 AM
   
RE:Create Download link in Repeater
Hi Jan,

I'm sorry. I'm still new with Kentico. Could you show me how to include

?disposition=attachment into the transformation?

Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/2/2013 3:14:38 AM
   
RE:Create Download link in Repeater
Hello,

It depends if the url already contains some query string or not:

1) It does not -> Eval("Pdf1")+"?disposition=attachment"
2) It does -> Eval("Pdf1")+"&disposition=attachment"

Best regards,
Jan Hermann

User avatar
Member
Member
afique-resolvtech - 12/2/2013 3:34:30 AM
   
RE:Create Download link in Repeater
Hi,

I already tried both of them but still it doesn't worked.

Do you have any other suggestion?

Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/2/2013 3:41:05 AM
   
RE:Create Download link in Repeater
Hello,

I have tested it with no issue. Could you please post your transformation to check its code?

Best regards,
Jan Hermann

User avatar
Member
Member
afique-resolvtech - 12/2/2013 3:47:07 AM
   
RE:Create Download link in Repeater
Hi,

Thanks for helping me. Here is the code.
<style type="text/css">
.tftable {font-size:11px;color:#333333;width:90%;border-width: 1px;border-color: #729ea5;border-collapse: collapse;}
.tftable th {font-size:11px;background-color:#acc8cc;border-width: 1px;padding: 4px;border-style: solid;border-color: #729ea5;text-align:left;}
.tftable tr {background-color:#ffffff;}
.tftable td {font-size:11px;border-width: 1px;padding: 4px;border-style: solid;border-color: #729ea5;}
.tftable tr:hover {background-color:#ffff99;}
</style>

<table class="tftable" border="1" align=center>

<tr><td width=12%><%# Eval("NoSiri") %></td><td width=51%><%# Eval("Tajuk") %></td>
<td width=12%><a class="header bold" href="<%# Eval("Pdf1") %>" >File</a><br><a class="header bold" href="<%# Eval("Pdf2") %>"><%# Eval("NamaPdf2", true) %></a></td>
<td width=15%><a class="header bold" href="<%# Eval("Pdf1") %>"><%# Eval("NamaPdf1", true) %></a><br><a class="header bold" href="<%# Eval("Pdf2") %>"><%# Eval("NamaPdf2", true) %></a></td></tr>
</table>

I want to make user can download the pdf file when they click "File"

Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/2/2013 3:52:08 AM
   
RE:Create Download link in Repeater
Hello,

Please try the code below:
<table class="tftable" border="1" align=center>

<tr><td width=12%><%# Eval("NoSiri") %></td><td width=51%><%# Eval("Tajuk") %></td>
<td width=12%><a class="header bold" href="<%# Eval("Pdf1")+"&disposition=attachment" %>" >File</a><br><a class="header bold" href="<%# Eval("Pdf2")+"&disposition=attachment" %>"><%# Eval("NamaPdf2", true) %></a></td>
<td width=15%><a class="header bold" href="<%# Eval("Pdf1")+"&disposition=attachment" %>"><%# Eval("NamaPdf1", true) %></a><br><a class="header bold" href="<%# Eval("Pdf2")+"&disposition=attachment" %>"><%# Eval("NamaPdf2", true) %></a></td></tr>
</table>

Best regards,
Jan Hermann

User avatar
Member
Member
afique-resolvtech - 12/2/2013 4:08:30 AM
   
RE:Create Download link in Repeater
Hi,

The document still cannot automatically be downloaded. If I use Internet Download Manager, then the document will directly downloaded.

What transformation that I wanted is similar to

CorporateSite.Transformations.MediaLibrarySelectedItem

When I click download, the document will be downloadable.


Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/2/2013 5:46:34 AM
   
RE:Create Download link in Repeater
Hello,

Are you selection a file from media libraries when using that media selection control? Could you please check if the Site Manager -> Settings -> Content -> Media -> Use permanent URLs is checked?

Best regards,
Jan Hermann

User avatar
Member
Member
afique-resolvtech - 12/2/2013 5:53:26 AM
   
RE:Create Download link in Repeater
Hi Jan,

Yes. I do select the file from media libraries using media selection control.

Regarding,

Site Manager -> Settings -> Content -> Media -> Use permanent URLs is checked?

Do I have to check it? Mine is still not checked yet.

Thanks

User avatar
Kentico Support
Kentico Support
kentico_janh - 12/2/2013 5:58:48 AM
   
RE:Create Download link in Repeater
Hello,

Yes, the checkbox needs to be checked since the image needs to be handled by our getmedia handler. So please check it and select those images in your media selection control once again to get updated url.

Best regards,
Jan Hermann

User avatar
Member
Member
afique-resolvtech - 12/2/2013 7:27:15 AM
   
RE:Create Download link in Repeater
Hi Jan,

I already replied to you in email support@kentico.com

Thanks

User avatar
Member
Member
afique-resolvtech - 12/2/2013 8:30:05 AM
   
RE:Create Download link in Repeater
Just to share with others that having the same problem:-- (Credit to Jan Hermann)

For my case, I'm using custom table Media Selection. I stored my PDF files in Media Library.

As conclusion:

1. Make sure that you checked this first
Site Manager -> Settings -> Content -> Media -> Use permanent URLs

2. To make a download link for PDF File
<a class="header bold" href="<%# Eval("Pdf1")+"&disposition=attachment" %>">Download File</a>


3. To make view mode for PDF file
<a class="header bold" href="<%# Eval("Pdf1")+"&disposition=inline" %>">View File</a>

Thank you