3
Answers

Open uploaded file without using Javascript

ramesh s

ramesh s

7y
200
1
Hi,
 
we have an asp.net application, initially user filled the form with uploaded file once submitted the page then shows last 10 transactions in the dynamically created html table. The uploaded file is anchor tag when click on link (html anchor tag) the file displays in the new browser. To view page in codebehind dynamically created anchor tag as shown below
 
for (int x-0; x <rowscount; x++)
string strpath = strLocation;
link = @"<a href=""javascript:goLink(' " + strPath + @" ' ) "">" + row["filename"].ToString() + "</a>"
 }
 
javascript funciton
---------------------- 
function goLink(file)
{
strUrl = 'file:' + file;
linkNewWin = window.opne(strUrl, linkNewWin);
linkNewWin.focus();
 } 
 
my requirement is without using javascript function need to same achieve. 
 
Please suggest. 
 
Thanks,
Ramesh 
Answers (3)
0
Ruchi Sharavat

Ruchi Sharavat

NA 77 202 7y
Why don't you provide full url in href and target as blank in codebehined file while generating anchor like:
 
 link = @"<a href="'www.example.com/" + strPath + @" ' ) "">" + row["filename"].ToString() + " target='_blank' </a>"
 
So that it will open the exact url in new window. 
Accepted
0
ramesh s

ramesh s

NA 78 1.5k 7y
Thanks Ruchi/Gokhul for giving suggestion.
 
Ruchi,
 
I want to give link only file like text/doc/pdf not web page. Hence I have used as below, it is working in local/dev server but UAT server it is not working.  
link = @"<a href="'file:" + strPath + @" ' ) "">" + row["filename"].ToString() + " target='_blank' </a>" 
 
Getting  error message when click on link 
 
            The Page can't be displayed
  •    Make sure the web address is correct
  •    Look for the page with your search engine
  •    Refresh the page in a few minues
 
 
The file location path I have access in Dev server but in UAT I don't have access to that location. Due to that it is not working? Without access to that location also it should be work. Please suggest.
 
0
Gokhul Varman

Gokhul Varman

NA 10.7k 9.4k 7y
you can get a clear solution about it by reffering the given link:https://stackoverflow.com/questions/2198470/javascript-uploading-a-file-without-a-file