ASP.NET AJAX Slider skips stepshttp://forums.asp.net/t/1799790.aspx/1?ASP+NET+AJAX+Slider+skips+stepsMon, 07 May 2012 08:25:30 -040017997904964223http://forums.asp.net/p/1799790/4964223.aspx/1?ASP+NET+AJAX+Slider+skips+stepsASP.NET AJAX Slider skips steps <p>We are using multiple slider extenders on a page, and on some of them it kind of skips steps. For example, one slider has the values minimum 0 and maximum 10, and the steps property is set to 10. But when you slide it, it always skips 5, so you go from 1-4 and then skip 5 and then 6-10. So you can never choose 5.</p> <p>The same happens on many of the sliders on the page (even though they have different minimums, maximums and step values).</p> <p>Any idea on what we have messed up?</p> <pre class="prettyprint">&lt;p&gt; &lt;span class=&quot;helpText&quot;&gt;Number Music stream per hour&lt;/span&gt; &lt;asp:HyperLink ID=&quot;lnkMusicStream&quot; runat=&quot;server&quot;&gt;&lt;/asp:HyperLink&gt; &lt;span class=&quot;maptextimg&quot;&gt; &lt;img class=&quot;helpTxtImg&quot; src=&quot;~/html/images/buttons/help_icon.png&quot; alt=&quot;help&quot; title=&quot;&lt;%=getNoOfMusicStreamHelpText() %&gt;&quot; /&gt; &lt;/span&gt; &lt;span class=&quot;numbers&quot;&gt; &lt;asp:Label ID=&quot;lblMusicIntervals&quot; runat=&quot;server&quot; /&gt; &lt;/span&gt; &lt;/p&gt; &lt;p&gt; &lt;span&gt; &lt;asp:TextBox ID=&quot;txtMusicStream&quot; runat=&quot;server&quot; AutoPostBack=&quot;true&quot; /&gt; &lt;span class=&quot;size&quot;&gt; &lt;asp:Label ID=&quot;lbltxtMusicStream&quot; runat=&quot;server&quot; /&gt;&lt;/span&gt; &lt;ajaxToolkit:SliderExtender ID=&quot;txtMusicStream_SliderExtender&quot; runat=&quot;server&quot; TargetControlID=&quot;txtMusicStream&quot; BehaviorID=&quot;txtMusicStream&quot; BoundControlID=&quot;lbltxtMusicStream&quot; EnableKeyboard=&quot;true&quot; TooltipText=&quot;{0}&quot; HandleCssClass=&quot;handleBar&quot; HandleImageUrl=&quot;~/html/images/buttons/handle.png&quot;&gt; &lt;/ajaxToolkit:SliderExtender&gt; &lt;/span&gt; &lt;/p&gt; txtMusicStream_SliderExtender.Maximum = Sliders.GetSliderValues(SliderType.Streaming)[&quot;MaximumMusic&quot;]; //10 txtMusicStream_SliderExtender.Minimum = Sliders.GetSliderValues(SliderType.Streaming)[&quot;MinimumMusic&quot;]; //1</pre> <pre class="prettyprint">txtMusicStream_SliderExtender.Steps = int.Parse((txtMusicStream_SliderExtender.Maximum / Sliders.GetSliderValues(SliderType.Streaming)["MusicSteps"]).ToString());</pre> <p><br> <br> </p> 2012-05-03T17:25:59-04:004964263http://forums.asp.net/p/1799790/4964263.aspx/1?Re+ASP+NET+AJAX+Slider+skips+stepsRe: ASP.NET AJAX Slider skips steps <p>The code looks fine, but post whats the value in&nbsp;MusicSteps. Also Try changing the BoundControlID to the text box and try setting value 5 to the textbox and see if the slider changes position.&nbsp;</p> 2012-05-03T17:49:13-04:004965270http://forums.asp.net/p/1799790/4965270.aspx/1?Re+ASP+NET+AJAX+Slider+skips+stepsRe: ASP.NET AJAX Slider skips steps <p>Hi,</p> <p>Please refer to this thread: <a href="http://forums.asp.net/p/1794447/4942320.aspx/1?Re&#43;SliderExtender&#43;half&#43;step&#43;issue"> http://forums.asp.net/p/1794447/4942320.aspx/1?Re&#43;SliderExtender&#43;half&#43;step&#43;issue</a>.</p> <p>You are have the same issue.</p> 2012-05-04T09:22:07-04:004965807http://forums.asp.net/p/1799790/4965807.aspx/1?Re+ASP+NET+AJAX+Slider+skips+stepsRe: ASP.NET AJAX Slider skips steps <p>Thanks,&nbsp;</p> <p>I did try the solution but it only fix for situation where decimal are handled. In my case there is no decimals.&nbsp;</p> <p>I came up wit hthe following:</p> <p>I've found that the &nbsp;setting of the steps are &quot;discrete steps&quot;, what it's actually means is left to be clearly defined (for my understanding). But when then minimum value of the slider is 0 ,then you need to add 1 to the actual value of your steps.</p> <p>i.e : if slider1.Max =5 and slider1.Min =0 and slider1.steps=5 then the value 2 will be skipped in favor of 3.</p> <p>The rationale behind if im right is that it actually divide the range in 2 equal part and if the mean point is a decimal it rounds it to the higher integer and jump that one.</p> 2012-05-04T14:07:39-04:004968604http://forums.asp.net/p/1799790/4968604.aspx/1?Re+ASP+NET+AJAX+Slider+skips+stepsRe: ASP.NET AJAX Slider skips steps <p>Hi,</p> <p>Yes, you could edit the code as I said:</p> <pre class="prettyprint">&lt;script type=&quot;text/javascript&quot;&gt; Sys.Extended.UI.SliderBehavior.prototype._getNearestStepValue = function (value) { if (this._steps == 0) return value; var extent = this._maximum - this._minimum; if (extent == 0) return value; var delta = extent / (this._steps - 1); if (value / delta == 0.5) { return value; } else return Math.round(value / delta) * delta &#43; this._minimum; }; &lt;/script&gt;</pre> <p></p> 2012-05-07T08:25:30-04:00