Asp – fileUpload control appearance

asp.net

I use fileUpload control in asp.net web page, so how could I control the "browse" button, just like any other button?

etc. I want to change "browse button" back color, border style.

Thank you in advance.

Best Answer

how could I control the "browse" button, just like any other button?

What makes you sure there will be a browse button? That's up to the web browser; some might not have a text-plus-browse arrangment at all. In particular Safari arranges the control quite differently.

For reasons of security, and because there is no standardisation about what a file upload control should look like, CSS gives you almost no control of the style of file upload controls.

Whilst the opacity hack mentioned in phoenix's link does kind of work, I wouldn't recommend it at all. There's no guarantee of getting the ‘clickable’ part of the input control lined up with the part of your ersatz control that looks clickable. Even on a single browser, different fonts and other settings will mess it up. For example on my browser with the quirksmode example only the right half of the textbox is clickable to open the browse dialogue; clicking the faux-button does nothing and clicking the left edge of focuses the faux-textbox. With fake-input you will be offering a shoddy and in the worst case broken experience to many of your visitors.

Live with the default upload styling, or augment it with a Flash uploader in the progressive-enhancement manner.