• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 526
  • Last Modified:

Problem with upload control display and behavior

I am having problems with the display and behavior of an upload control where the button is showing up inside the upload text field instead of to the right of it and although it does allow me to browse, it doesn't show the filename and path in the text field portion after I select a file. I would also like to know how to get at the upload button itself to style it like the submit button. All code is here http://www.curriersystems.com/testUpload.aspx including all styles and there is no .cs code yet

Actually, here is my upload control code. Nothing special

                <b>Select a File to Upload</b><br />
                <asp:FileUpload ID="fu" runat="server" />
  • 2
  • 2
2 Solutions
In your styles,

table fu

should be

table .fu

and the control should be written in ASP.NET like

<asp:FileUpload Id="fu" runat="server" cssClass="fu" />

as fu is used for name/ID.  Just specifying fu in styles means that the browser is thinking fu is the name of an element (e.g. <fu/>, like <p>).
Some schools of thought also say that you shouldn't bother styling a file upload element as different browsers render them very differently, and they are unique in their behaviour.
BobHavertyComhAuthor Commented:
Well it does seem to be responding to style attributes now. I suppose that since this control is being generated server side that "cssclass" needs to be used rather than "class". I can live without styling it I suppose. But the upload button is still appearing inside of the text field and it is blocking the file name from appearing inside of the text field. I just published the file again so that you can see it
BobHavertyComhAuthor Commented:
It turns out that the upload button was not covering the text field, it was just a function of some browsers putting the button on the right and some putting it on the left and my color attribute manages what color the text is inside the file upload text field and that color was set to the same color as the background, so the file info was showing up, it just had the same color as the text field background.

You are right about different browsers doing whatever they want. IE gives me an ugly grey background for the text field no matter what. FF and Chrome seem to respond to styles. After reading some articles, it appears to be more of a security issue than anything else and different browsers are going to do whatever they think they need to do with this control. It is possible to still style this, with a lot of hassle and shaky workarounds, but I will leave that for later and at least now I can begin testing your other solution. Excellent, spot on info. Thanks again.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now