Search code examples
asp.nettextboxmultilineautogrow

How to grow a textbox to match size of input for data entry dynamically (ASP.NET)


I'd like to add a description field to an application that can be as long as several lines (or even paragraphs) or as short as a one-liner.

Instead of taking up a lot of screen real estate or have scroll bars, it would be preferable to have the textbox grow based on its input.

On IE6 adding Style="overflow-y:visible" accomplishes this nicely (both on display of read only, and if we are in edit mode).

However, it has no effect on Firefox, or IE7 for that matter.

Is there a relatively easy fix for this?

Thanks!


Solution

  • You can accomplish this using jquery if you want to go down that route. It's a nice effect, kind of like the comment textarea in facebook.

    http://javascriptly.com/examples/jquery-grab-bag/autogrow-textarea.html