Asp: FileUpload edit the message "No file"

I just need to know if there is a way to change the message shown Asp:FileUploadwhen no file was selected.

This message

Thanks.

+4
source share
7 answers

You replace the text with your own message using the pseduo-class CSS :after. You can declare a class as follows:

.bar:after {
    content:"Please select a file";
    background-color:white;
}

FileUpload. . , , , , jQuery .removeClass ( , FileUpload "foo" ):

$('#foo').change(function() {
    $(this).removeClass("bar");
})

: http://jsfiddle.net/5zhuL/2/

, , , Webkit- (Chrome, Opera, Safari), .

+3

http://jsfiddle.net/ZDgRG/

. . css, , , :

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];
    }
 };
+4

, . Chrome .

+1

, ASP.NET type='file' FileUpload. CSS, -, value .

+1

CSS . "No file selected".

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

</style>
0

http://jsfiddle.net/Lsgbx5ne/1/

input[type=file]{
  color:transparent;
}
input[type=file]:after {
  color: #000;
  content:" Cool!";
}

:

  • Pure css
0

window.pressed = function(){
    var a = document.getElementById('aa');
    if(!(a.value == ""))
    {
        var theSplit = a.value.split('\\');
        fileLabel.innerHTML = theSplit[theSplit.length-1];
    }
};
input[type=file]{
    width:90px;
    color:transparent;
}
<div>
<input type='file' title="Choose a video please" id="aa" onchange="pressed()">
<label id="fileLabel">Choose file</label>
</div>
Hide result
0

All Articles