How to Persist HtmlInputFile Value through postback?

D

Dave Adler

Is there any way to retain the value of an HtmlInputFile control through a
postback?

I do some server side validation on the page when it is submitted and if an
error occurs on the page the HtmlInputFile control value is blank after the
postback. The EnableViewState for the control is set to true. I can't put
the postedFile.filename value in a hidden control and then put it back into
the HtmlInputFile control on postback because the postedFile.filename and
the value properties are read-only.

Any ideas?

Thanks in advance

David
 
P

Patrice Scribe

No for security reasons.

You could probably still perhaps do tricky things such as using (inline)
frames (allowing to keep a part that doesn't get refreshed).

Patrice
 
T

Teemu Keiski

Hi,

no there isn't as this is security related (if you could write to it, you
could theoretically upload files from client without user knowing that)

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

Is there any way to retain the value of an HtmlInputFile control through a
postback?

I do some server side validation on the page when it is submitted and if an
error occurs on the page the HtmlInputFile control value is blank after the
postback. The EnableViewState for the control is set to true. I can't put
the postedFile.filename value in a hidden control and then put it back into
the HtmlInputFile control on postback because the postedFile.filename and
the value properties are read-only.

Any ideas?

Thanks in advance

David
 
B

bruce barker

you shouldn't do much serverside validation on HtmlInputFile , as the file
is actually uploaded, you shouldn't require a second upload. at least cache
the file, and do secondary processing after.

-- bruce (sqlwork.com)
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top