Hi guys,

This one is a bit out of left field but someone somewhere must have tried this before.

Does anyone out there know how to control the width of the filepath textbox in a fileupload control?

I have a form with a comment textbox, a filetype dropdown and a fileupload control

I want the comment textbox, the dropdown and the textbox part of the fileupload to all be the same width and line up together on my form but the width property of the fileupload control sets that of the whole control (Textbox and browse button)

I tried setting the width of the other two controls and lining up that way but:

  1. How do I know that this will look okay in other browsers?
  2. My dropdown looks wierd as it is cutting off text - I'd rather resize the other two controls.

Recommended Answers

All 3 Replies

well, check your code-behind file i:e. the HTML file of the page and get the width of the textbox and make the width of the FileUpload control same with the textbox. You can do this in design time

well, check your code-behind file i:e. the HTML file of the page and get the width of the textbox and make the width of the FileUpload control same with the textbox. You can do this in design time

Thats what I was saying, that does not work as the width specifies both the textbox part and the Button part of the upload control i.e. it is rendered as a single HTML tag:

<input type="file" name="ctl00$BodyContent$FileUpload1" id="BodyContent_FileUpload1" title="Browse to Document" />

I'm trying to get the "text part" to line up with my textbox and the browse button part to be to the right of them... I hate doing it by eye on the design mode as i'd rather be able to give a specific width.

Sure it does, the textbox path is also part of the FileUpload control so you cant set a property separately for it. Tou can expand the width of the control from the IDE in design time. And besides, the FileUpload control is browser dependent. You would see the textbox in Browsers like Mozilla firefox but don expect to see it in Google Chrome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.