That's perfect. I wasn't aware of "
OnClientBeforeValueChange".
Here is my final cut with checkbox enabled fixed range behavior.
<
script
type
=
"text/javascript"
>
var avoidRecusrsion = false;
var rangeBetweenHandles;
function OnClientBeforeValueChange(sender, args) {
if ($get("<%= CheckBox1.ClientID %>").checked) {
rangeBetweenHandles = sender.get_selectionEnd() - sender.get_selectionStart();
if (avoidRecusrsion) return;
var newValue = args.get_newValue();
var sliderDragHandles = sender.get_dragHandles();
var activeDragHandle = sender.get_activeHandle();
if (!activeDragHandle) return;
avoidRecusrsion = true;
// In case we are moving the selectionStart dragHandle.
if (activeDragHandle == sliderDragHandles[0]) {
if (newValue + rangeBetweenHandles > sender.get_maximumValue()) {
args.set_cancel(true);
}
}
// In case we are moving the selectionEnd dragHandle.
else {
if (newValue - rangeBetweenHandles <
sender.get_minimumValue
()) {
args.set_cancel(true);
}
}
avoidRecusrsion
=
false
;
}
}
function OnClientValueChange(sender, args) {
if ($get("<%= CheckBox1.ClientID %>").checked) {
if (avoidRecusrsion) return;
var newValue = args.get_newValue();
var sliderDragHandles = sender.get_dragHandles();
var activeDragHandle = sender.get_activeHandle();
if (!activeDragHandle) return;
avoidRecusrsion = true;
// In case we are moving the selectionStart dragHandle.
if (activeDragHandle == sliderDragHandles[0]) {
var rangeEnd = newValue + rangeBetweenHandles;
sender.set_selectionEnd(rangeEnd);
}
// In case we are moving the selectionEnd dragHandle.
else {
var rangeStart = newValue - rangeBetweenHandles;
sender.set_selectionStart(rangeStart);
}
avoidRecusrsion = false;
}
}
</
script
>
<
telerik:RadSlider
ID
=
"RadSlider1"
runat
=
"server"
SmallChange
=
"5"
LargeChange
=
"10"
ItemType
=
"tick"
IsSelectionRangeEnabled
=
"true"
Width
=
"400px"
Height
=
"60px"
TrackPosition
=
"BottomRight"
SelectionStart
=
"0"
SelectionEnd
=
"30"
OnClientBeforeValueChange
=
"OnClientBeforeValueChange"
OnClientValueChange
=
"OnClientValueChange"
>
</
telerik:RadSlider
>
<
br
/>
<
asp:CheckBox
ID
=
"CheckBox1"
runat
=
"server"
Text
=
"Enable fixed range"
Checked
=
"true"
/>
Thanks for your help and Telerik Points.