ASP.Net TextBox Bug

Not sure if this is fixed in .Net 1.1, (got to check) but if you use an ASP.Net TextBox control and set the textmode to MultiLine, it will generate a textarea tag.  The bug is that if you set the size thru height and width attributes, it will convert them to a style attribute, but only for IE, not Netscape or Mozilla.

So for
<asp:TextBox id="TextBox1" TextMode="MultiLine" runat="server" Height="200px" Width="200px"></asp:TextBox>

You get this in IE:

<textarea name="TextBox1" id="TextBox1" style="height:200px;width:200px;"></textarea>

But this in other browsers:

<textarea name="TextBox1" id="TextBox1"></textarea>

Which gives you a very small textarea.

The work around is to either use a CssClass, or make sure you also set the width and height via the rows and columns attributes.  IE ignores them if you set height and width thru the style, and Mozilla uses them to generate the height and width.


If you want an example, just check out any comments page on this site in Mozilla.

Don XML

3 Comments

  • You might also try using columns and rows to make this work in both netscape and ie:





    &lt;asp:textbox BackColor=&quot;White&quot; ForeColor=&quot;Black&quot; id=&quot;txtUserAgreement&quot; Columns=65 Rows=10 runat=&quot;server&quot; TextMode=&quot;MultiLine&quot; Height=&quot;150px&quot; Width=&quot;570px&quot;&gt;&lt;/asp:textbox&gt;

  • Thx for the tip Rick :)

  • Hi there,

    I would like to know if there's any realtion between the number of pixels and the number of rows/columns .... kind of 1 row = ??pixels and 1 col = ??pixels



    Thanks

Comments have been disabled for this content.