How to open a file by clicking on HyperLink

删除回忆录丶 提交于 2019-12-05 09:37:16

The file:/// is for resources on your own machine.

To open files on a server, you will have to link to urls on the server. Use:

HttpContext.Current.Request.ResolveUrl(pathOnServer);

Change your code like this:

<asp:Repeater ID="dokumente" runat="server">
    <ItemTemplate>
        <tr>
            <td><asp:HyperLink ID="HyperLink4" runat="server" Text='<%# Eval("DokuTyp") %>' NavigateUrl='<%# HttpContext.Current.Request.ResolveUrl(Eval("File")) %>'></asp:HyperLink></td>
            <td><%# Eval("Description")%></td>
            <td><%# Eval("Date") %></td>
            <td><%# Eval("File") %></td>
        </tr>
    </ItemTemplate>
</asp:Repeater>

Where Server

The "file" protocol opens a file in the user computer. I guess you have to read the file on the server-side and call a Resposne.Write.

If you want find file on server you can use Server.MapPath method; "file://" is not correct url if you want find file on server

NavigateUrl=<%#Server.MapPath(DataBinder.Eval("File"))%>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!