executing javascript function causes unwanted directory listing
I have an ASP.NET app (c# codebehind) in which I alow the user to browse for a file using <input type=file>. Clicking on another link calls a javascript function which is to open the designated file and read its contents into a textbox. I am pretty sure I can do all of that without dificulty... BUT for reasons that I don't understand, simply calling this javascript function will result in a directory listing (or attempted directory listing)... In fact, I even tried putting a return statement at the very beginning of the function so that none of the other code will execute, and even that causes this stupid directory listing...
How can I make this directory listing go away???
Here is a snippet of the HTML code:
Code:
<P>Select a file<br>
<input id="File1" type="file" size="40" name="File1">
<a href="" onclick="Preview()">Preview the file contents</a></P>
<P><STRONG>File contents:</STRONG><BR>
<asp:textbox id="TextBox3" runat="server" Height="74px" Width="554px"></asp:textbox></P>
Here is the source of the javascript function:
Code:
function Preview()
{
try
{
// get the filename...
var file_val = eval("document.Form1.File1");
var strFileName = file_val.value;
// open the file, read it, put it in the text box...
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(strFileName, 1);
var str = f.ReadAll();
//alert(str);
document.Form1.TextBox3.value = str;
f.Close();
}
catch (Exception)
{
alert("Cannot open file :( " + Exception.message);
}
}
Re: executing javascript function causes unwanted directory listing
Is the actual script being run on the client-side or server-side?