add HtmlInputFile at runtime and read the file after upload

  • Thread starter Thread starter Anton Sommer
  • Start date Start date
A

Anton Sommer

Hello folks,

I create a couple of HtmlInputFile controls dynamically at runtime but I
have no idea how to read out the file that could be uploaded from some of
the controls. Just recreating exactly the same controls after postback
doesn't work on Html Controls.


Thank you



Anton
 
Hi there

To read the file from one of the controls( which are being created dynamically), you might want to use this technique

You can add HtmlInputFileControls inside a panel
After some button is clicked, you can navigate through the control collection of that panel
Comparing the control types with that of static HTMLInputFile control, you can identify whether created control is of file type or not
Then you can check the PostedFile for that control like this--
fileControl.PostedFile ==null if no file is uploaded using this control then it will return true
And if file is uploaded then it will return false

Hope this helps

Thanks and Regards
Amol Kulkarni.
 
thank you Natty you are a genius that was it.


but what is this good for
Remember to add enctype="multipart/form-data" attribute to Html Form.


thank you


Anton
 
Back
Top