Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello,

We have a dynamically created fileupload control. We want to fetch the id and filename before postback or clicking on save button using JavaScript

Regards,
Prasad
Posted

 
Share this answer
 
Comments
Maciej Los 22-Jun-12 3:17am    
Good answer, my 5!
Prasad_Kulkarni 22-Jun-12 3:23am    
Thank you Isomac! :)
Manas Bhardwaj 22-Jun-12 6:13am    
Good ref +5
Prasad_Kulkarni 22-Jun-12 6:29am    
Thank you Manas!
Ok. And the issue is?

You say you already have created a fileupload control dynamically. Now, you have a fileupload control.

Before submitting the page, on button click, in Javascript, get the filecontrol and it's details.
Sample:
XML
var myFControl = document.getElementById("<%= myFileUpload1.ClientID %>");
alert("Filename selected: " + myFControl.value);


Refer for HTML Dom object of fileupload control: http://www.w3schools.com/jsref/dom_obj_fileupload.asp[^]
 
Share this answer
 
Comments
Maciej Los 22-Jun-12 3:18am    
Good answer, my 5!
PrasadRaoMangalore 22-Jun-12 3:23am    
How to fetch the values from JavaScript variable on postback through ASPX form?
Sandeep Mewara 22-Jun-12 3:25am    
:doh:

Define a client click for submit button and then handle the above code.
Use ASP Button and you have OnClientClick property exposed to be used directly. Or add a onclick Attribute to button in code behind.
Sandeep Mewara 22-Jun-12 3:24am    
Thanks Mac!
Prasad_Kulkarni 22-Jun-12 3:23am    
Good answer +5!
look This[^]

This[^]
This[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900