ksg
ksg

Reputation: 4067

Empty FileUpload Text Using Javascript

I've a fileupload controller in my asp.net form.I've to empty the fileupload text using javascript on radiobutton click.

How will we do that.Here's my code...

<asp:RadioButton ID="rbnImage" runat="server" Text="Image" GroupName="a" 
onclick="SetVisibility(this.id)"

Javascript goes here

function SetVisibility(id) {
        if (id == 'rbnImage') {
            document.getElementById('fupLogo').style.visibility = 'visible';
            document.getElementById('fupLogo').value = '';                
            document.getElementById('txtText').style.visibility = 'hidden';
        }

    }

This code is not working.Its working for textbox.

Upvotes: 1

Views: 1647

Answers (1)

Hadas
Hadas

Reputation: 10374

You can't set the value of File upload.

Try this trick:

var browse=document.getElementById(control);  
var newbrowse= browse.cloneNode(false);   
browse.parentNode.replaceChild(newbrowse ,browse);

Upvotes: 2

Related Questions