Link to home
Start Free TrialLog in
Avatar of GileadIT
GileadITFlag for United States of America

asked on

Resizing a textbox when populated with text - vb

I am trying to resize textboxes on an page. I have successfully implemented a script to expand the textboxes as a user types (see below), but when the form is populated with text from a database, the size of the textbox is not expanded. Does anyone have an idea on how I might be able to remedy this?   Thanks - Joe

Expand textbox as user types:
        function AutoExpand(txtbox) {
   = "1px";
   = (25 + txtbox.scrollHeight) + "px";

<asp:TextBox ID="txtEvent" runat="server" CssClass="FormsTextbox" Rows="3" TextMode="MultiLine" style="overflow:hidden" onkeydown="AutoExpand(this)" ></asp:TextBox>

Open in new window

Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

you may need to call the function AutoExpand when ur page is loading...
Avatar of GileadIT
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GileadIT


Although the reply to add the javascript to my page load would have worked, the work to be done on the script itself to make it work is not something I can do. Making a subroutine in vb to handle to work seemed easier.