Introduction:
In this article I will explain how to change or increase the textbox height dynamically using asp.net
In this article I will explain how to change or increase the textbox height dynamically using asp.net
Description:
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
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="http://www.w3.org/1999/xhtml">
<head>
<title>Automatic Resize TextBox</title>
<script type="text/javascript">
function setHeight(txtdesc) {
txtdesc.style.height = txtdesc.scrollHeight + "px";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtDesc" runat= "server" TextMode="MultiLine" onkeyup="setHeight(this);" onkeydown="setHeight(this);" />
</form>
</body>
</html>
| |
Demo
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
9 comments :
Hey thanks to u..it was of gr8 help :)
It is really great....beautiful solution.......Keep it up...Thanks....
Thanks - works great in IE but Firefox keeps making the box bigger even when removing lines
Any solution for this example so that it can work in other browsers than IE?Anyway thanks for the article
A VERY BIG THANK!!!!!!!!!!!!!!!!!!!! YOU!!!!!!!!!!!!!!!!!!!!
You are a genius, thank you so much!
tnq so much........
i have to set text box lengt nly 7 character how can i
its not working
Hai this is not Working....While Im removing my characters size is going to bib
Note: Only a member of this blog may post a comment.