如何給上傳控制項上色【HOW TO SET CSS FOR THE CONTROL OF FILEUPLOAD】

來源:互聯網
上載者:User

今天遇到一個文章,老外問我如何給FILEUPLOAD 控制項上色,就連老外的MVP也說不是容易的事情,呵呵。

其實有些時候我們只要變通下就可以解決這樣的小問題,看看My Code。

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css">
        #divFileUpload input
        {
            border-color: Olive;
            border-style: solid;
            border-width: 1px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="divFileUpload">
        <asp:FileUpload ID="FileUploadCSSDemo" runat="server" />
    </div>
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
    </form>
</body>
</html>
注意代碼裡面的CSS部分,其實道理很簡單,我們知道FILEUPLOAD 會被瀏覽器解釋成為以INPUT為標記的HTML元素,所以我就把樣式應用給這個特定的DIV【divFileUpload】裡面的HTML元素,所以如果你運行My Code,你會看到樣式只會應用到FILEUPLOAD控制項上,而不會應用到其它可以解釋為INPUT的HTML元素上。        #divFileUpload input
        {
            border-color: Olive;
            border-style: solid;
            border-width: 1px;
        }

這個是我給老外回答問題的源地址:

http://forums.asp.net/p/1423781/3176963.aspx#3176963

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.