Add dynamic FileUpload Control at runtime in asp.net using javascirpt
In our projects there may be a situation at design time where we don’t know how many FileUpload control we need in a web page. So we have to add FileUpload Control at runtime as much as user of our page requires.
In this post I am showing you how to add File upload Control at runtime in asp.net
We will use javascript to add FileUpload control at runtime and than save the files uploaded by the user.
JavaScript code to add FileUpload control at runtime
I have created two methods for adding and removing FileUpload at runtime. AddFile() method will add a FileUpload control and a remove button. RemoveFile(file) method will remove the FileUpload control if added by mistake.
HTML or .ASPX page code
Code for .cs file
To get the all files selected by the web form user, we are using the Request.Files, which will return a collection of files. we loop through Collection of Request.Files and assinging each file to HttpPostedFile object and saving file with SaveAs() method of the HttpPostedFile class.
fdfdfdf
really vary fine code..
it works in very correct manner....
Nice Code,Easy to understand it