Hi, I have a problem with the slider extender that I cannot work out.
My first implimentation worked just fine - I wanted it to step from 0-360 degrees in 11.25 degree steps, so I set the Minimum to 0, the Maximium to 360 and Steps to 33. This worked fine.
The client now wants it start at 5.625 degrees and end at 354.375 degrees, still stepping in 11.25 degree increments. For this I should just need to change the max and min accordingly and change the Steps to 32.
The problem is that the slider now does a HALF STEP at the begining and a HALF STEP at the end. All the other steps are the correct increment but are half a step out of phase. Also when you move the slider to the leftmost position (5.625), it snaps back
to the first half step position (11.25).
Here's my code that's giving the half step errors:
valans
Member
2 Points
3 Posts
SliderExtender half step issue
Apr 19, 2012 12:48 AM|LINK
Hi, I have a problem with the slider extender that I cannot work out.
My first implimentation worked just fine - I wanted it to step from 0-360 degrees in 11.25 degree steps, so I set the Minimum to 0, the Maximium to 360 and Steps to 33. This worked fine.
The client now wants it start at 5.625 degrees and end at 354.375 degrees, still stepping in 11.25 degree increments. For this I should just need to change the max and min accordingly and change the Steps to 32.
The problem is that the slider now does a HALF STEP at the begining and a HALF STEP at the end. All the other steps are the correct increment but are half a step out of phase. Also when you move the slider to the leftmost position (5.625), it snaps back to the first half step position (11.25).
Here's my code that's giving the half step errors:
<asp:SliderExtender ID="SliderH" TargetControlID="txtH" Orientation="Horizontal" Maximum="354.375" Minimum="5.625" Steps="32" Decimals="3" Length="356" Runat="server" ></asp:SliderExtender>Any help would be much appreciated,
Alan
Song-Tian - ...
All-Star
43715 Points
4304 Posts
Microsoft
Re: SliderExtender half step issue
Apr 20, 2012 07:34 AM|LINK
Hi,
This is because Math.round(0.5)=1. So you could add follow script below </form> to avoid that:
<script type="text/javascript"> 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 + this._minimum; }; </script>Feedback to us
Develop and promote your apps in Windows Store
valans
Member
2 Points
3 Posts
Re: SliderExtender half step issue
Apr 20, 2012 10:52 AM|LINK
Many thanks, this has fixed the issue. I am surprised that this isn't handled in the control.