How to clear the textbox content in a FileUpload control in ASP.NET?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The ASP.NET
FileUploadcontrol maps to the HTMLinputelement withtype="file". This element is considered Read-only and you cannot change it directly.However, there seem to be atleast three workarounds to accomplish the goal of “clearing the field” :
a. Reset the form, either using script or by providing a
input type="reset"button.b. Re-establish the input field in the DOM by setting its attributes again:
c. Recreate the
innerHTMLof the field from the existinginnerHTMLas demonstrated here: