c# - Differentiate between multiple dynamic fileupload controls -


i'm dynamically adding multiple fileuploads asp.net page. user able create , delete these fileuploads page. code written in javascript / jquery:

var opleverpuntcounter = 0;         function addopleverpunt() {             var $opleverpuntcontainer = $('#opleverpuntcontainer');             var div = '';             var divid = 'opleverpunt_' + opleverpuntcounter;             div = '<div id="' + divid + '"><br />upload afbeelding situatie vooraf <input id="opleverpuntbeforefile_' + opleverpuntcounter + '" name="opleverpuntbeforefile_' + opleverpuntcounter + '" type="file" accept="image/*" capture="camera" /><br /><label for="opleverpuntdescriptionbefore_' + opleverpuntcounter + '">situatie omschrijving vooraf</label><br /><textarea type="text" id="opleverpuntdescriptionbefore_' + opleverpuntcounter + '" name="opleverpuntdescriptionbefore_' + opleverpuntcounter + '" rows="5" cols="100"></textarea><br />upload afbeelding situatie achteraf <input id="opleverpuntafterfile_' + opleverpuntcounter + '" name="opleverpuntafterfile_' + opleverpuntcounter + '" type="file" accept="image/*" capture="camera" /><br /><label for="opleverpuntdescriptionafter_' + opleverpuntcounter + '">situatie omschrijving achteraf</label><br /><textarea type="text" id="opleverpuntdescriptionafter_' + opleverpuntcounter + '" name="opleverpuntdescriptionafter_' + opleverpuntcounter + '" rows="5" cols="100"></textarea><br /><input id="btn_' + opleverpuntcounter + '" type="button" value="remove x" class="smallbutton" /></div>';             $opleverpuntcontainer.append(div);             $('#btn_' + opleverpuntcounter).click(function () { removeopleverpunt(divid); });             opleverpuntcounter++;         }         function removeopleverpunt(element) {             var $element = $('#' + element);             $element.remove();         } 

it adds 2 fileupload controls on each addopleverpunt() call. name , id both generated , unique each fileupload.

html:

<div id="opleverpuntcontainer"> </div> 

back @ server-side use following code , store uploaded files:

for (int = 0; <= request.files.count - 1; i++) {     httppostedfile postedfile = request.files(i);     if (postedfile.contentlength > 0) {         //store postedfile here         //(left out improve question readability)     } } 

the fileuploads aren't asp:fileupload controls regular input fileupload controls.

is there way differentiate between opleverpuntbeforefile_x , opleverpuntafterfile_x? (x generated number)

if i'm able difference @ serverside, able store opleverpuntbeforefile in 1 entity , opleverpuntafterfile in another.

suggestions , answers in either c# or vb.net fine.

you can access html control name:

for (int = 0; <= request.files.count - 1; i++)             {                 httppostedfile postedfile = request.files[i];                 var controlname = request.files.keys[i];                 if (postedfile.contentlength > 0)                 {                     //store postedfile here                     //(left out improve question readability)                 }             } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -