add HtmlInputFile at runtime and read the file after upload

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
 
G

Guest

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.
 
A

Anton Sommer

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top