Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

Slider / Client-side Events

RadSlider with single drag handle:
Range RadSlider:
Clear log Event log:

  • Client side events

    The following client-side events are available:
    • OnClientLoad - raised when the slider is initialized
    • OnClientValueChanging - raised before the value of the slider changes
    • OnClientValueChanged - raised when the value of the slider changes
    • OnClientSlideStart - raised when a drag handle of the slider starts sliding
    • OnClientSlide - raised when a drag handle of the slider is sliding
    • OnClientSlideEnd - raised when a drag handle of the slider finishes sliding

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" AutoEventWireup="false" Inherits="Telerik.Web.Examples.Slider.ClientSideEvents.DefaultCS"
        CodeFile="DefaultCS.aspx.cs" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
    </head>
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>

        <script type="text/javascript">
            /* Slider with single drag handle */
            function OnClientLoad(sender,args)
            {
                logEvent("Slider is loaded. Initial value is " + sender.get_value() + ".");
            }

            function OnClientValueChanging(sender,args)
            {
                logEvent("Changing value of slider from " + sender.get_value() + " to " + args.get_newValue() + ".");
            }

            function OnClientValueChanged(sender,args)
            {
                logEvent("Changed value of slider from " + args.get_oldValue() + " to " + sender.get_value() + ".");
            }

            function OnClientSlideStart(sender,args)
            {
                logEvent("Drag handle of slider began sliding.");
            }

            function OnClientSlide(sender,args)
            {
                logEvent("Drag handle of slider is sliding.");
            }

            function OnClientSlideEnd(sender,args)
            {
                logEvent("Drag handle of slider finished sliding.");
            }

            /* Range slider */
            function OnClientLoad2(sender,args)
            {
                logEvent("Range slider is loaded. Initial range is [" + sender.get_selectionStart() + "; " + sender.get_selectionEnd() + "].");
            }

            function OnClientValueChanging2(sender,args)
            {
                var newValue = args.get_newValue();
                var isFirstHandleActive = GetActiveDragHandle(sender);

                logEvent("Changing range of range slider from [" + sender.get_selectionStart() + "; " + sender.get_selectionEnd() + "] to [" +
                    (isFirstHandleActive ? newValue : sender.get_selectionStart()) + "; " +
                    (isFirstHandleActive ? sender.get_selectionEnd() : newValue) + "].");
            }

            function OnClientValueChanged2(sender,args)
            {
                var oldValue = args.get_oldValue();
                var isFirstHandleActive = GetActiveDragHandle(sender);

                logEvent("Changed range of range slider from [" +
                    (isFirstHandleActive ? oldValue : sender.get_selectionStart()) + "; " +
                    (isFirstHandleActive ? sender.get_selectionEnd() : oldValue) + "] to [" +
                    sender.get_selectionStart() + "; " + sender.get_selectionEnd() + "].");
            }

            function OnClientSlideStart2(sender,args)
            {
                var handleText = GetActiveDragHandle(sender) ? "First" : "Second";
                logEvent(handleText + " drag handle of range slider began sliding.");
            }

            function OnClientSlide2(sender,args)
            {
                var handleText = GetActiveDragHandle(sender) ? "First" : "Second";
                logEvent(handleText + " drag handle of range slider is sliding.");
            }

            function OnClientSlideEnd2(sender,args)
            {
                var handleText = GetActiveDragHandle(sender) ? "First" : "Second";
                logEvent(handleText + " drag handle of range slider finished sliding.");
            }

            function GetActiveDragHandle(slider)
            {
                var dragHandles = slider.get_dragHandles();
                var activeDragHandle = slider.get_activeHandle();

                // The first drag handle is active.
                if(activeDragHandle === dragHandles[0]) return true;
                // The second drag handle is active.
                return false;
            }
        </script>

        <table style="width:750px;font-size:11px;">
            <tr>
                <td style="border:solid 1px #ccc;text-align:center;">
                    RadSlider with single drag handle:
                
                    <telerik:RadSlider runat="server" ID="RadSlider1" style="margin-top:20px;margin-bottom:6px;" Width="368px" Value="60" OnClientLoad="OnClientLoad"
                        OnClientValueChanging="OnClientValueChanging" OnClientValueChanged="OnClientValueChanged"
                        OnClientSlideStart="OnClientSlideStart" OnClientSlide="OnClientSlide" OnClientSlideEnd="OnClientSlideEnd" />
                </td>
                <td style="border:solid 1px #ccc;text-align:center;">
                    Range RadSlider:<br />
                
                    <telerik:RadSlider runat="server" ID="RadSlider2" style="margin-top:20px;margin-bottom:6px;" Width="368px" IsSelectionRangeEnabled="true"
                        SelectionStart="20" SelectionEnd="80" OnClientLoad="OnClientLoad2" OnClientValueChanging="OnClientValueChanging2"
                        OnClientValueChanged="OnClientValueChanged2" OnClientSlideStart="OnClientSlideStart2"
                        OnClientSlide="OnClientSlide2" OnClientSlideEnd="OnClientSlideEnd2" />
                </td>
            </tr>
        </table>
        <qsf:EventLogConsole ID="EventLogConsole1" runat="server" AllowClear="true" />
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451