Resetting an HtmlInputFile Control

  • Thread starter Nathan Sokalski
  • Start date
N

Nathan Sokalski

I have a System.Web.UI.HtmlControls.HtmlInputFile control that I want to
reset after uploading the file. However, all of the properties seem to be
ReadOnly. How can I programmatically reset the control so that the user does
not accidentally upload the same file twice? Thanks.
 
L

Lau Lei Cheong

The control's content will be automatically cleared when the page is posted.
(It's one of the control that will not preserve values)
And I believe a "Form.Reset()" javascript will clear it too.
 
A

Alan Silver

The control's content will be automatically cleared when the page is posted.
(It's one of the control that will not preserve values)
And I believe a "Form.Reset()" javascript will clear it too.

Is there any way to retain the value after postback? I have a form where
I need to do some server-side validation, and if the user chooses a file
and posts, but the server-side validation fails, they are shown the page
again for re-entry of data. Trouble is that the file input control has
now lost its setting, so the user has to choose the file again (if they
notice).

Any suggestions? TIA
 

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,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top