Extract control from literal

I have a Literal control in an ASP.Net application, I populate this literal with a large number of FileUploads files, as shown below:

Literal1.Text += string.Format("<input id='File{0}' type='file' /><br/>",n++); 

where n is a number that is not my concern, it is being processed. FileUploads successfully adds to the page, now I want to transfer (or whatever you call it) literal text to several FileUploads files (n elements) and save them all in one reverse transfer. HOW CAN THIS LINE BE LIKE 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 of which indicates the file is being downloaded as a string, IS IT POSSIBLE TO DEMAND THESE LINES FOR DOWNLOAD FILES AND DOWNLOAD THEIR FILES?

+4
source share
1 answer

Give the names of your inputs and by checking back Request["inputName"] for the values.

 lit.Text += String.Format("<input id='File{0}' name='File{0}' type='file' /><br/>", n++); 

When Request["File1"] back, the names of your files are in Request["File1"] , Request["File2"] , etc.

PS: Perhaps all you need is to get the files from Request.Files (if the form has enctype="multipart/form-data" ).

0
source

Source: https://habr.com/ru/post/1442579/


All Articles