I am working on a site it is in VB.net, I need to create a multiline text box. I am able to increase the height of the textbox as number of characters increases using Javascript, however when page get refreshed or loaded again then textbox size comes back to the default height.
Code:
<asp:TextBox ID="txtDescription" runat="server" TextMode="MultiLine" rows="3" onkeypress="grow();" Width="590px"></asp:TextBox>
var TEXTAREA_LINE_HEIGHT = 2;
function grow(source)
{
var textarea = document.getElementById(source);
var newHeight = textarea.scrollHeight;
var currentHeight = textarea.clientHeight;
if (newHeight > currentHeight) {
textarea.style.height = newHeight + 5 * TEXTAREA_LINE_HEIGHT + 'px';
}
}
Any help would be highly appreciated.
Hi I found out the solution for my problem. Please write the following code on txtDescription_Load event: