aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Resize multiline textbox dynamically based on text using javascript

Feb 25, 2011

In this article I will explain how to change or increase the textbox height dynamically using


I have one textbox my requirement is if user enters text in texbox that height of textbox needs to be adjusting with text for that I have written one JavaScript function to adjust textbox height here one more point is we need to set the
TextMode="MultiLine" property for textbox to adjust textbox height 
Now design your aspx page like this

<html xmlns="">
<title>Automatic Resize TextBox</title>
<script type="text/javascript">
function setHeight(txtdesc) { = txtdesc.scrollHeight + "px";
<form id="form1" runat="server">
<asp:TextBox ID="txtDesc" runat= "server" TextMode="MultiLine"  onkeyup="setHeight(this);" onkeydown="setHeight(this);" />


If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Roopa said...

Hey thanks to was of gr8 help :)

Tushar said...

It is really great....beautiful solution.......Keep it up...Thanks....

Anonymous said...

Thanks - works great in IE but Firefox keeps making the box bigger even when removing lines

Anonymous said...

Any solution for this example so that it can work in other browsers than IE?Anyway thanks for the article

Anonymous said...

A VERY BIG THANK!!!!!!!!!!!!!!!!!!!! YOU!!!!!!!!!!!!!!!!!!!!

willzinhow said...

You are a genius, thank you so much!

ram charan said...

tnq so much........
i have to set text box lengt nly 7 character how can i

Ashish said...

its not working

Veersh Dachepally said...

Hai this is not Working....While Im removing my characters size is going to bib

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.