Last post May 05, 2017 09:58 AM by Cathy Zou
May 04, 2017 07:48 AM|georgenaffah|LINK
I have a datalist that is displaying data from the database, the link path is also in the database , it represents link to folder that contains pdf files , when datalist is generated link is created , but when i click on the link , nothing occurs, below
is my code
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# Eval("completepath") %>' Text='<%# Eval("ArticleName") %>' />
below is strucuture of table :
articleID | ArticleName | Article | Type | completepath
1 AIO some test CC D:\i\123-xwz.pdf
any suggestion ?
May 05, 2017 09:58 AM|Cathy Zou|LINK
According to your description, you bound the completepath filed to the HyperLink’s NavigateUrl property. Then you want to open .pdf file by clicking HyperLink. Which is impracticable for the completepath is a absolute path.
So my suggestion is that you could place the .pdf file in a folder in your project and put the relative path of the .pdf into the completepath field in your database.
After that when you click the link, you could get the content in it.
Something as below:
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/file/hello.pdf" Text='~/file/hello.pdf' />
Output screenshot as follows:
Hope above could be helpful to you.