I have a Literal control in my ASP.Net application, I fill this literal with a lot of FileUploads as below:
Literal1.Text += string.Format("<input id='File{0}' type='file' /><br/>",n++);
where n is a number that is not my worry, it is handled. FileUploads successfully add to page, now I want to cast (or whatever you call it) the literal text into several FileUploads (n items) and Save them all in one postback. HOW CAN I BEHAVE THIS STRING AS FILEUPLOAD?
I have tried this so far:
string[] fileUploads = Literal1.Text.Split(new string[] { "<br/>" },
StringSplitOptions.RemoveEmptyEntries);
this gives me an array of strings each indicating a fileupload as string, IS IT POSSIBLE TO CAST THESE STRINGS TO FILEUPLOADS AND UPLOAD THEIR FILES?
Give your inputs names, and on postback check Request["inputName"]
for the values..
lit.Text += String.Format("<input id='File{0}' name='File{0}' type='file' /><br/>", n++);
On postback your file names are in Request["File1"]
, Request["File2"]
, etc.
PS: Maybe all you need is getting the files themselves from Request.Files
(assuming the form has enctype="multipart/form-data"
).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.