Auto-scroll to the bottom of a multiline textbox when page loads

Using the below javascript code snippet, you can auto scroll to the bottom of an asp:TextBox, which’s TextMode property is set to Multiline.

Let’s say the textbox is like below

<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"></asp:TextBox>

Then the javascript code should look like below

window.onload=function myScroll() {
   var x = document.getElementById("<%=textboxid.ClientID%>");
   var h = x.clientHeight;
   x.scrollTop = h;

Now, when the page loads, the scroll of the Multiline textbox would go to the bottom.

No comments: