This is a migrated thread and some comments may be shown as answers.

Detecting scroll position in multiline RadTextBox

2 Answers 102 Views
Input
This is a migrated thread and some comments may be shown as answers.
Hunter
Top achievements
Rank 1
Hunter asked on 31 May 2012, 10:10 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Vasil
Telerik team
answered on 05 Jun 2012, 10:30 AM
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.
0
Hunter
Top achievements
Rank 1
answered on 05 Jun 2012, 07:52 PM
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)" />
Tags
Input
Asked by
Hunter
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Hunter
Top achievements
Rank 1
Share this question
or