Today I met a post where a foreigner asked me how to color the fileupload control. Even the MVP of a foreigner said it was not easy.
In fact, sometimes we only need to work around to solve such a small problem. Let's look at myCode.
<% @ 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 >
Pay attention to the CSS part in the Code. In fact, the principle is very simple. We know that fileupload will be interpreted by the browser as an HTML element marked with input, so I will apply the style to the HTML element in divfileupload of this specific Div. So if you run my code, you will see that the style will only be applied to the fileupload control, it will not be applied to other HTML elements that can be interpreted as input.# Divfileupload Input
{
Border-color : Olive ;
Border-style : Solid ;
Border-Width : 1px ;
}
This is the source address for me to answer questions to foreigners:
Http://forums.asp.net/p/1423781/3176963.aspx#3176963