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>
this code isnt working
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.
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 %>");
This one worked for me.
$(document).on('hidden.bs.modal', '#modalPopup1', function (event) {
$("#fileUpload1").val("");
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.