Asp:FileUpload edit "No file selected" message

Guillermo Oramas R. picture Guillermo Oramas R. · Nov 25, 2013 · Viewed 15.7k times · Source

I just need to know if there's a way to change the message shown by the Asp:FileUpload when no file as been selected.

This message

Thanks.

Answer

Chandan Kumar picture Chandan Kumar · Nov 25, 2013

http://jsfiddle.net/ZDgRG/

See above link. I use css to hide the default text and use a label to show what I want:

html

<div>
      <input type='file' title="Choose a video please" id="aa" onchange="pressed()">
      <label id="fileLabel">Choose file</label>
</div>

css

input[type=file]{
    width:90px;
    color:transparent;
}

javascript

window.pressed = function(){
    var a = document.getElementById('aa');
    if(a.value == "")
    {
        fileLabel.innerHTML = "Choose file";
    }
    else
    {
        var theSplit = a.value.split('\\');
        fileLabel.innerHTML = theSplit[theSplit.length-1];
    }
 };