A simple questions

M

Marko Vuksanovic

I am trying to get the FilePath element of the FileUpload control to a JS
variable. As I am pretty new to JS I have no idea how to achieve that. I
would kindly ask someone to point me to the right direction,... such as
where I should start with JS and possibly the solution to my concrete
problem....

This is the relevant code:
<script type="text/javascript">
var fileUploadPath;
function UploadButtonClick()
{
//get the FilePath property to the fileUploadPath variable
alert(fileUploadPath);
}
</script>



<asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"
OnClientClick="UploadButtonClick()"> </asp:Button>

Thanks in advance,
M.V.
 
J

Jacek Stawicki

U¿ytkownik "Marko Vuksanovic said:
I am trying to get the FilePath element of the FileUpload control to a JS
variable. As I am pretty new to JS I have no idea how to achieve that. I
would kindly ask someone to point me to the right direction,... such as
where I should start with JS and possibly the solution to my concrete
problem....

This is the relevant code:
<script type="text/javascript">
var fileUploadPath;
function UploadButtonClick()
{
//get the FilePath property to the fileUploadPath variable
alert(fileUploadPath);
}
</script>



<asp:FileUpload id="FileUpload" runat="server"> </asp:FileUpload>
<asp:Button id="Upload" Text="Upload file" runat="server"
OnClientClick="UploadButtonClick()"> </asp:Button>


It is a client-side JavaScript problem, so the solution is simple.
Just read the "value" property of the HTML file-input control.
Let's assume, that this control name is FileUpload then:

fileUploadPath = document.form_name.fileUploadPath.value;

ps.
Why do you need this ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top