Home All Groups Group Topic Archive Search About

Automatically adjust TextBox's height

Author
29 Jun 2005 2:34 AM
H.
Hi,

I have a questions regarding the TextBox webcontrol. I already have a
textbox in fix width. But the number of contents (text) in the textbox is
arbitrary. I set the textbox as mutlilines. I want to dynamically adjust the
textbox 's height to fits for the number of characters in the textbox so as
not to show vertical scroll bar.  For instance , if there are 3 rows , the
textbox's height equals to 3 rows , if there are 5 rows , the textbox's
height equals to 5 rows. How can I do this ?

Thank you,
H.

Author
29 Jun 2005 6:31 PM
Michael Baltic
You would need to default it to multiline, with 1 row and set the style to
hide the scrollbars.  Then in Javascript, change the number of lines based on
the number of characters entered.

An asp textbox renders an input type=text when the control is single line
and a textarea when the control is multiline.

So, you won't be able to dynamically change it from single to multi on the
client.

It is trivial on the server.
--
Staff Consultant II - Enterprise Web Services - Cardinal Solutions Group

Future Business Model - National City Mortgage


Show quoteHide quote
"H." wrote:

> Hi,
>
> I have a questions regarding the TextBox webcontrol. I already have a
> textbox in fix width. But the number of contents (text) in the textbox is
> arbitrary. I set the textbox as mutlilines. I want to dynamically adjust the
> textbox 's height to fits for the number of characters in the textbox so as
> not to show vertical scroll bar.  For instance , if there are 3 rows , the
> textbox's height equals to 3 rows , if there are 5 rows , the textbox's
> height equals to 5 rows. How can I do this ?
>
> Thank you,
> H.