C# FileUpload width property not working in FF

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Proogeren
    New Member
    • May 2007
    • 36

    C# FileUpload width property not working in FF

    While using the FileUpload control in firefox the width property is not set.

    <asp:FileUplo ad ID="dd" runat="server" width="300px" />

    In firefox the control is rendered as following
    <input type="file" name="ctl00$Con tentPlaceHolder 1$dd" id="ctl00_Conte ntPlaceHolder1_ dd" style="width:30 0px;" />

    Anyone know why width is ignored here?

    (works in IE7)
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    <input> is an inline element, hence it should not be styleable with width. IE, as usual, is not performing correctly by allowing what you have. You can try using 'display:block' on the form or input tag, can't remember, but I don't recall if that works. You may have to use the 'size' attribute.

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Originally posted by drhowarddrfine
      <input> is an inline element, hence it should not be styleable with width. IE, as usual, is not performing correctly by allowing what you have. You can try using 'display:block' on the form or input tag, can't remember, but I don't recall if that works. You may have to use the 'size' attribute.
      DrHowardDrFine is correct about the <input> element.
      According to the w3c website on the Html Input Tag, there is no "width" attribute for the input tag. However, there is a "size" attribute.

      Maybe try setting the size attribute as he has suggested.

      What doesn't quite make sense to me is that I can set the width of my text box using css.

      Eg. The following code works fine in IE and FireFox...it will draw a TextBox 50px wide.......
      [code=html]
      <input name="myTextBox " type="text" style="width:50 px;" />
      [/code]

      Anyone care to explain why this happens?
      I've been looking it up for a little while now but I'm still confused.

      Have you tried setting the width of the UploadControl using css?

      -Frinny

      Comment

      • drhowarddrfine
        Recognized Expert Expert
        • Sep 2006
        • 7434

        #4
        User agent conformance.
        CSS 2.1 does not define which properties apply to form controls and frames, or how CSS can be used to style them. User agents may apply CSS properties to these elements. Authors are recommended to treat such support as experimental. A future level of CSS may specify this further.

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Originally posted by drhowarddrfine
          That explains it!
          Thanks a lot for the information!

          :)

          -Frinny

          Comment

          • ka3m0n
            New Member
            • Sep 2008
            • 1

            #6
            ********Solutio n ************
            use "Size". It's not a property of the control but it's an attribute of a text input control. (Works for FF & IE)

            <asp:FileUplo ad ID="upImage" runat="server" Size="50" />

            Comment

            Working...