0

I have a datagrid that needs one of the fields to hyperlink to a document housed on another server. The path is in this format: \\server\location\file.doc, but when I click on the cell in the data grid it becomes: http://myASPServer/Subfolder/server/location.file.doc. Is there any way that I can force this to go to the correct location? I know that you can prevent this for external websites by adding ftp:// or http://, but this does not seem to work for opening up this server location. Any suggestions?

shawleigh17
  • 1,147
  • 4
  • 22
  • 42

1 Answers1

1

I believe your answer can be found here on the asp.net forums http://forums.asp.net/t/1140909.aspx/1 - accepted answer from there below for your convenience.

<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink Text="TextField" id="myHL" runat="server"
 NavigateUrl='<%# "file:///" + DataBinder.Eval(Container.DataItem, "Path").ToString() %>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>

I believe you need to prefix your links with file:/// for it would be file:///\\server\location\file.doc

Luke Baughan
  • 4,658
  • 3
  • 31
  • 54
  • Okay, I did that, and this is what I have: ` `. Now, when I try clicking on the link, it doesn't do anything. – shawleigh17 Aug 06 '12 at 19:22
  • When I scroll over the link, it has changed the url to start with file:///// instead of file:///\\. In firefox, if I look in firebug, the url is correct, but it doesn't seem to link properly. – shawleigh17 Aug 06 '12 at 19:24
  • 1
    Found this blog post http://rubenlaguna.com/wp/2007/04/20/firefox-and-file-windows-unc-paths/index.html/ which explains whats happening and a work around - try it in IE and chrome and see what happens with those! – Luke Baughan Aug 06 '12 at 19:27
  • 1
    Oh and heres a Stack post which should also help! http://stackoverflow.com/questions/5317834/workaround-for-href-file-in-firefox – Luke Baughan Aug 06 '12 at 19:28