I need to make a Asp.net control to upload multiple files that sends the files through Ajax.
This control could be used to store the files on a Folder or in the Database, the persistense is going to be decided by the Classes that will use my control, not the Control itself. So i need to achieve a level of flexibility here.
The uploaded files will be stored my Control Class like a List of Files, until the class using my control execute the "official post" which will consume and then finally release the class.
In a simple example a Form using my control would consume the List generated by all the uploads made through my control and upong Save, the form would read my list and persist it the way is best.
The problem here is the approach:
I can't use a updatePanel because it doesn't allow for fileinputs and (afaik) won't keep the state of purelly javascript generated input=files.
It's not possible to use the WebMethod property to send the data since it requires my Method to be static which makes it impossible to feed a in memory object using this method.
The other option would be to use handmade Ajax, which is not that difficult, but I'm not sure how Asp.net will behave, does it keep states between Ajax Calls? Can I access the same in memory object from different calls? will i have to keep track of viewstates or use sessions? is it viable to use sessions or the viewstate(!) to keep uploaded files?
Reforcing: The problem is NOT Uploading the files with ajax, I'm using blueimp.github.com/jQuery-File-Upload , the problem is keeping track of them in the serverside without persisting.
Example
Let me try to explain a little better:
0) I have a control, this control has a property that is a List of the files - List<files> FilesUploaded
;
1) On each ajax upload , I add the coming File into the list FilesUploaded.Add(FileComingFromAjax)
2) My controls goes into a form (any form), and when I save the Form BtSave.Click()
, the Form class will need to get the list of files and persist so: they access it like this AnyonesForm.MyControl.FilesUploaded
. Notice that the files are in Memory and not in the disk or the database.
My doubt is, Will the files be kept after each request? namelly:
Will the method call through ajax, use the Same List?
When i submit the main form, Will the List be accessible by the form class with the files I just uploaded?