Detecting scroll position in multiline RadTextBox

3 posts, 1 answers
  1. Hunter
    Hunter avatar
    11 posts
    Member since:
    Feb 2012

    Posted 31 May 2012 Link to this post

    I have a multiline RadTextBox with enough text to make the scrollbar visible. Is it possible to detect when the user scrolls to the bottom?

    I've done this before with a System.Windows.Forms.RichTextBox, which fires a VScroll event.

    private void agreementTextbox_VScroll(object sender, EventArgs e)
    {
        Point pt = agreementTextbox.GetPositionFromCharIndex(agreementTextbox.TextLength);
        if (agreementTextbox.ClientRectangle.Contains(pt))
        {
            //user has scrolled down all the way
        }
    }

    However, I don't see how to do this with a RadTextBox.
  2. Answer
    Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 05 Jun 2012 Link to this post

    Hello Hunter,

    The RadTextBox itself does not expose such event. However you could use the DOM scroll event:
    http://www.quirksmode.org/dom/events/scroll.html
    <script type="text/javascript">
        function scrollHandler(sender, args)
        {
            var textBox = $find(sender.id);
        }
    </script>
    <telerik:RadTextBox runat="server" ID="RadTextBox1" TextMode="MultiLine" Height="100px" Rows="20" onscroll="scrollHandler(this,event)" />


    Kind regards,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hunter
    Hunter avatar
    11 posts
    Member since:
    Feb 2012

    Posted 05 Jun 2012 Link to this post

    Thanks, Vasil. That worked. I did it like this:

    <script type="text/javascript">
        function scrollHandler(sender, args)
        {
            var txt = document.getElementById("RadTextBox1");
            if (txt.scrollTop == (txt.scrollHeight - txt.clientHeight))
            {
                //user has scrolled all the way down
            }
        }
    </script>
    <telerik:RadTextBox runat="server" ID="RadTextBox1" TextMode="MultiLine" Height="100px" Rows="20" onscroll="scrollHandler(this,event)" />
Back to Top