How to set slider control value from ASP.NET AJAX Control Toolkit with JavaScript function?

How to install slider control from ASP.NET AJAX Control Toolkit with JavaScript function? Is it possible?

+1
source share
1 answer

Sure! You must set the value of the asp:TextBox control associated with your SliderExtender with the required value. So, for this ASP markup:

 <asp:TextBox ID="sliderBox" runat="server" ClientIDMode="Static"></asp:TextBox> <asp:SliderExtender ID="sliderBox_SliderExtender" runat="server" Enabled="True" Maximum="100" Minimum="0" TargetControlID="sliderBox"> </asp:SliderExtender> <asp:Button ID="incButton" runat="server" Text="incrementSlider" onclientclick="change();" /> 

Mainly:

  • a asp:TextBox named sliderBox (to use SliderExtender )
  • a asp:SliderExtender sliderBox_SliderExtender (mostly default values)
  • a asp:Button named incButton. This is an onClientClick property that calls the javascript change() function

And here is the change() function:

 <script type="text/javascript"> function change() { document.getElementById("sliderBox").value += 10; } </script> 

The change() function increments the value in the asp:TextBox control by 10, thereby increasing the position of the sliders each time you click the button.

+4
source

Source: https://habr.com/ru/post/1391066/


All Articles