Piotr Perak
Piotr Perak

Reputation: 11088

Resizing Textbox/textarea to fit text

I need to create user control with Texbox Textmode="Multiline" or html textarea.

When in edit mode Textbox/textarea has to be resizable. I can use some jquery plugin for this. But in read only mode this Textbox/textarea is disabled and it must be automatically resized (height) to fit the text. Even if text takes pages. I could just hide Textbox/textarea in read only mode and display text in div but I would like to keep edit and readonly page look same.

Any ideas?

Upvotes: 1

Views: 7271

Answers (1)

user191966
user191966

Reputation:

Why have textarea/input in readonly mode - versus using js to switch back and forth between that control and a DIV or a P tag (to display the text), where simply by not setting the height (or setting it to height:auto) that box would automatically size to contain all text?

Also, unless your surrounding content doesn't allow that, enable resizing the textarea to the user; see http://davidwalsh.name/textarea-resize

Upvotes: 1

Related Questions