Set scroll position inside radwindow

2 posts, 1 answers
  1. James
    James avatar
    10 posts
    Member since:
    Jan 2013

    Posted 07 Oct 2013 Link to this post

    I have a RadWindow that scrolls vertically, since its content is rather long.

    Is there a way to set the scroll position inside of the radwindow via javascript? Specifically I want to scroll to the top of the radwindow after a user clicks a button within it.
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3599 posts

    Posted 08 Oct 2013 Link to this post

    Hello James,

    You can use the scrollTop property of the element with the scrollbar and the OnClientShow event of the RadWindow to set it to the desired value. It is done in the same manner as with any other div:
    <div style="width: 100px; height: 100px; overflow: auto;" id="test">
        <div style="height: 1000px; background: yellow;">
        </div>
    </div>
    <telerik:RadWindow ID="RadWindow1" runat="server" OnClientShow="OnClientShow" OpenerElementID="Button1">
        <ContentTemplate>
            <div id="mainHolder" style="width: 100%; height: 100%; overflow: auto;">
                <div style="height: 1000px; background: yellow;">
                </div>
            </div>
        </ContentTemplate>
    </telerik:RadWindow>
    <asp:Button ID="Button1" Text="open the RadWindow" runat="server" />
    <script type="text/javascript">
        function OnClientShow(sender, args)
        {
            $telerik.$($get("mainHolder")).scrollTop(200);
        }
     
        function pageLoad()
        {
            $telerik.$("#test").scrollTop(200);
        }
    </script>




    Regards,
    Marin Bratanov
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top