Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: how to clear context of a FileUpload control of asp.net

Tags:

jquery

I know to clear context of a textbox, using $('#textbox1').val(""); But how to clear context of a FileUpload control. I mean to erase the content of it's textbox. For example, I first choose a file using FileUpload control, which it shows c:\user\1.png. Now I want to clear it by using jQuery.

$('#FileUpload1').val(""); 

apprently does not work here.

like image 892
Steven Zack Avatar asked Oct 20 '25 10:10

Steven Zack


1 Answers

$('#FileUpload1').val("");

won't work on ie.

document.getElementById("#FileUpload1").createTextRange().execCommand('delete');` will work on ie

or you can use
var file = document.getElementById("<%=FileUpload1.ClientID%>"); $(file).parent().html($(file).parent().html());

like image 120
sav sharma Avatar answered Oct 21 '25 23:10

sav sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!