Faryal Imam Faryal Imam - 5 months ago 16
Javascript Question

how to clear fileupload text box inside a modal popup window in asp.net?

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

Answer

This one worked for me.

$(document).on('hidden.bs.modal', '#modalPopup1', function (event) {
        $("#fileUpload1").val("");
    });