Setting a TextBox 'width' with ASP.NET

By John Bowen, 27 April, 2008

Even though I've been using Firefox as my primary browser for months now, I still haven't spent much time checking some of my old (but production) code for compatibility. After taking a quick look, I can't believe customers haven't complained...

In that context, I noticed that Firefox doesn't respect the 'width' setting for the ASP.NET TextBox control. IE handles this just fine, but FireFox (and probably other browsers) just stick with the 'default' TextBox width, which is often too long/wide.

A quick Google search came up with this article, suggesting the use of the 'columns' attribute in the TextBox's definition. Firefox _does_ respect that attribute, and (yeah!) I'm able to size TextBox's pretty easily this way.

Thanks Kendall!

Filtered HTML

  • Web page addresses and email addresses turn into links automatically.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.