Setting Slider Value

2 posts, 1 answers
  1. Ben
    Ben avatar
    31 posts
    Member since:
    Feb 2013

    Posted 14 Feb 2013 Link to this post

    Hi

    Is it possible to set the value of RadSlider through JavaScript based on a value in my textbox?  When I enter some value in the textbox then the slider should be set accordingly and vice-versa.
    Thanks
    Ben.
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 14 Feb 2013 Link to this post

    Hi Ben,

    It is possible to set the slider value through Javascript. Please have a look into the following code snippet to set the slider value from textbox as well as to set the textbox value from the slider. You can use the OnClientValueChanged event of the RadSlider to set the textbox value when the slider position is changed.

    ASPX:
    <asp:TextBox ID="TextBox1" runat="server" onblur="myFunction()"></asp:TextBox>
    <telerik:RadSlider ID="RadSlider" runat="server" MinimumValue="0" MaximumValue="100"
        OnClientValueChanged="OnClientValueChanged">
    </telerik:RadSlider>

    Javascript:
    <script type="text/javascript">
        function OnClientValueChanged(sender, eventArgs) {
            document.getElementById("TextBox1").value = sender.get_value();
        }
     
        function myFunction() {
            var slider = $find("<%= RadSlider.ClientID %>");
            slider.set_value(parseInt(document.getElementById("TextBox1").value));
        }
    </script>

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top