tags:

views:

56

answers:

6

Hi,

I m developing asp.net application in which I m opening HTML page that is stored on client machine on that page I have a link which will open aspx page on server, On that aspx page I have a button that will open another html page stored on client machine. Since I m new to web development Plz help me and suggest me some solutions for this ASAP.

Thanks....

Edited to add:

Is it possible to navigate between HTML Pages on Client machine and ASPX pages on server without uploading HMTL file on server. Can I use some javascript code on aspx page to open my locally stored HTML page...

+4  A: 

try this
<a href="file:///c:\whatever.txt">click to open whatever</a>

wozza
My HTML page is on client machine and <a Href="c:\file.html"/> not allow aspx server page to open this file.
shania
@shania: actually this *will* work **IF** you know what directory contains the user's html file...which you probably don't.
egrunin
+1  A: 

The only way you can access files on a client's machine is by them uploading it to you.

Babiker
I don't *think* they want access to the file, but instead want to fire an "open-file" command for the user.
Graphain
A: 

Is it possible to navigate between HTML Pages on Client machine and ASPX pages on server without uploading HMTL file on server. Can I use some javascript code on aspx page to open my locally stored HTML page...

shania
I added this to your question -- that's where people will see it.
egrunin
A: 

You cannot do this reliably, because the server doesn't know where the HTML page is (what drive, what directory).

If you explain why your are trying to do this, perhaps we can suggest an alternative design.

egrunin
A: 

Not quite sure what you are asking, but should create an open file dialogue. If you want the ASPX page to read the HTML file on users local machine then you need to upload it.

Tom Gullen
A: 

If I understand correctly, you have 2 problems:

  1. you need to redirect from your aspx page to a local html page
  2. you need to redirect from a local html page back to your server page

To solve nr 1 you will need to know the absolute location path to the html page on the client machine (ie. C:\SomePath\LocalFile.html) then do a link there:

 <a href="file:///C:\SomePath\LocalFile.html">

And no, it's not possible to access local files from javascript.

At most you can ASK the user to point to the local file (ie.via a file upload input) then intercept that event and use the path to that file.

   window.location.href=document.getElementById('fileInput').value;

but even that is riddled with problems as it will not work in some browsers,etc.

To solve nr2 you will probably need to add some javascript (which by default is turned off for local html files!!) and use "history.previous" to detect the path to your public aspx page. Something in the order of :

   window.location.href= history.previous.replace("myfirstpage.aspx","redirectedpage.aspx"); 

which will send someone that came to the current page from ,say, "http://www.publicserver.com/myfirstpage.aspx", will be redirected to "http://www.publicserver.com/redirectedpage.aspx",

Radu094