Link to home
Start Free TrialLog in
Avatar of claygarrett
claygarrett

asked on

Looping through HTMLInputFiles

I have HTMLFileInput fields with runat="server" like so:

<INPUT id="file1" type="file" name="file" runat="server">
<INPUT id="file2" type="file" name="file" runat="server">
<INPUT id="file3" type="file" name="file" runat="server">
...etc....

When the button is pressed to save the form/upload the files, I have a pretty lengthy sub that each of these boxes needs to be passed to.  Is there a way to do this via a looping structure of some sort, instead of me having to call the function once for each file field?

I want to avoid doing this:

-------------------------------------------
DoSomethingToMyFile(file1)
DoSomethingToMyFile(file2)
DoSomethingToMyFile(file3)

Function DoSomethingToMyFile(myFile as HTMLInputFile)
End Function
-------------------------------------------

because the page will have up to 30-40 file fields.  I'd rather do something to this effect:

-------------------------------------------
For i as Integer = 1 to intNumFiles
     DoSomethingToMyFile("file" & i)
Next

Function DoSomethingToMyFile(myFile as HTMLInputFile)
End Function
-------------------------------------------

You used to be able to do this in vbscript with the "Eval" statement - but I know that doesn't really apply in .NET.  Any ideas?

Thanks,
Clay
ASKER CERTIFIED SOLUTION
Avatar of jpatel18
jpatel18

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial