Asp:文件上传编辑“无文件选择”信息 [英] Asp:FileUpload edit "No file selected" message

查看:182
本文介绍了Asp:文件上传编辑“无文件选择”信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只需要知道当没有选择任何文件时,是否有更改由 Asp:FileUpload 显示的消息

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.

谢谢。

推荐答案

使用CSS pseduo类: $ c>。您可以声明这样的类:

You replace the text with your own message using CSS pseduo-class :after. You can declare a class like this one:

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

并将其分配给FileUpload控件。内容消息将替换原始消息。当然,根据文件选择你需要删除消息,你可以通过jQuery .removeClass (假设你的FileUpload的ID是foo)做这个:

And assign it to your FileUpload control. The content message will replace the original one. Of course upon file selection you need to remove the message, you can do this for example via jQuery .removeClass (assuming ID of your FileUpload is "foo"):

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

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

请注意,此解决方案似乎有效仅适用于Webkit浏览器(Chrome,Opera,Safari),您可能需要为他人提供替代方案。

Note that this solution seems to work Webkit-browser's only (Chrome, Opera, Safari) you may need an alternative for others.

这篇关于Asp:文件上传编辑“无文件选择”信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆