0

I am using an asp page where I want to have a hyperlink that, if clicked, will load an html page in the browser.\but as i user the asp:hyperlink and I am also giving the path of the html page where the page is stored. However, when clicked, it is not loading that html page.. i am using the hyperlink as:

<asp:HyperLink ID="hlinkTest" runat="server">Preview</asp:HyperLink>

and i am giving the url as

 hlinkTest.NavigateUrl = "file:///E:/user/aspnet_app/source/test.html";

what can be the better solution for getting html page in browser..

5
  • Where are you providing the Navigate URL in the code behind... Commented May 13, 2011 at 17:30
  • i am giving the navigate url on c# page.. Commented May 13, 2011 at 17:31
  • Where in the Page... Inside Page Load event or in which event exatcly. use hlinkTest.NavigateUrl = @"file://E:/user/aspnet_app/source/test.html"; Make sure the page exits... copy this URL to the browser address bar and enter. You should see a page... Commented May 13, 2011 at 17:31
  • when i enter the url on page it is showing the page but using hyperlink it is not showing.. Commented May 13, 2011 at 17:35
  • I've no idea why it's not... Perhaps you should try it with different browser or what... can you post the code and aspx of your page Commented May 13, 2011 at 17:39

3 Answers 3

1

I would be concerned that by trying to access a specific file location, you're opening yourself up for problems. You might have some real trouble porting the site to a new location.

If the target file is in the same folder as your hyperling source you could use:

hlinkText.NavigateUrl = "~/test.html";

Good luck.

Sign up to request clarification or add additional context in comments.

1 Comment

it is showing an error "Firefox doesn't know how to open this address, because the protocol (e) isn't associated with any program."
0

Try:

<a href="file:///E:/user/aspnet_app/source/test.html">Preview</a>

Comments

0

Don't forget that the client browser will be unable to load a file: url unless a file with that name and path exists and the user has read access to it. So in the OP's original example, unless the machine running the browser that's trying to load file:///E:/user/aspnet_app/source/test.html has a readable file at E:\user\aspnet_app\source\test.html, they're get a big fat error along the lines of file or directory does not exist or can't be found. Try giving the user an http: URL, absolute (http://www.mysite.org/foo/bar/baz.html) or relative (foo/bar/baz.html). If relative, the path will be taken relative to the URL of the current page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.