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 - asp.net vb

I am trying to resize textboxes on an asp.net 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:
<head>
<script>
        function AutoExpand(txtbox) {
            txtbox.style.height = "1px";
            txtbox.style.height = (25 + txtbox.scrollHeight) + "px";
        }
    </script>
</head>

<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...
ASKER CERTIFIED SOLUTION
Avatar of GileadIT
GileadIT
Flag of United States of America image

Link to home
membership
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

ASKER

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.