Clearing ASP.Net FileUpload Control in Javascript
The following script will help us to clear the FileUpload control in ASP.Net 2.0.
<script language="javascript">
function ClearFileUpload()
{
var fil = document.getElementById("FileUpload1");
fil.select();
n=fil.createTextRange();
n.execCommand('delete');
fil.focus();
}
</script>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" OnClientClick="ClearFileUpload()" Text="Clear" />
When we click the Clear button the FileUpload control will be cleared.
|