views:

116

answers:

3

When the user selects an item from a dropdownlist containing image names, I would like the FileUpload text box to be filled with a message I program such as "Replace this image with..." How would I do this?

+2  A: 

Security restrictions in certain browsers (IE at least) prevent you from being able to actually set the text of an <input type="file" /> element, which is what the FileUpload ASP.NET control renders.

I am on a project where we are trying to manipulate the appearance of file upload elements, and it's proving to be quite difficult to do in a cross-browser-compliant manner. I suggest looking at flash-based solutions such as Uploadify, which is more customizable.

John Bledsoe
+1  A: 

Due to the nature of the control, for security reasons you cannot manipulate it beyond some styling.

What you can do, however, is use a Flash or Silverlight based upload control. Or put your desired message in a label above the file input.

Bryan Batchelder
Yeah I was thinking about a label, but I was just wondering if there was another way besides making another control.
Justen
A: 

Not possible. The < input type="file" /> is part of the browser chrome. Some browsers don't show any text at all, so any solution would not be robust. As Bryan suggests, use a < label >.

graphicdivine