Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net LinkButton HyperLink problem

The following two controls on my page:

<asp:LinkButton ID="OpenLB" runat="server" >Open</asp:LinkButton>
<asp:HyperLink ID="OpenHL" runat="server">Open</asp:HyperLink>

I set them during page load like this:

OpenLB.PostBackUrl = @"file:\\web\documents-emails\doc1.docx";
OpenHL.NavigateUrl = @"file:\\web\documents-emails\doc1.docx";

OpenHL works, it opens the word file.

OpenLB doesnt work, when I click on it, I get a error pop-up that says:

Windows Internet Explorer Cannot find file 'file://web//documents-emails//doc1.docx'. Make sure the path or Internet address is correct.

It looks like the url is different or something, how can I fix this?

like image 335
Enriquev Avatar asked Feb 28 '23 10:02

Enriquev


1 Answers

The LinkButton works by posting the web page back to the server using the given url. It displays the button in the style of a hyperlink, but uses javascript to post the form back to the server at the given url. You won't be able to use it with a file: url since you can't POST to a local file. The HyperLink just creates an anchor which results in the location of the browser being set to the url when it is clicked.

like image 116
tvanfosson Avatar answered Mar 08 '23 01:03

tvanfosson