Title: how to clear fileupload text box inside a modal popup window in asp.net?
Tags: javascript;c#;jquery;asp.net;file-upload
Question: If user has selected the file but did not upload and hid the popup, the selected file should disappear (in other words fileupload textbox should be again showing "No File selected" )
$('#modal1').on('hidden.bs.modal', function (e) {
var fu = document.getElementById("fileupload1");
if (fu != null) {
document.getElementById("fileupload1").outerHTML = fu.outerHTML;
}
})
</script&gt;
this code isnt working

Here is the accepted answer: This one worked for me.
$(document).on('hidden.bs.modal', '#modalPopup1', function (event) {
$("#fileUpload1").val("");
});

Here is another answer: Use val(""):
$('#modal1').on('hidden.bs.modal', function (e) {
$("#fileupload1").val("");
When you assign an empty value to FileUpload it shows the default "No File Chosen" text.

Here is another answer: Take care fileupload1 looks like is an ASP.Net server-side FileUpload control.
so you should get its ID using the ClientID property, try this:
var fu = document.getElementById("<%= fileupload1.ClientID %&gt;");

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:05/11/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><c#><jquery><asp.net><file-upload>', 'Title': 'how to clear fileupload text box inside a modal popup window in asp.net?', 'ViewCount': 457, 'id': 37160982, 'user_AboutMe': None, 'user_AccountId': 8396344.0, 'user_DisplayName': 'Faryal Imam', 'user_Reputation': 83.0, 'user_Views': 10.0, 'user_id': 6303263.0}}