Iam using ajax controltoolkit slider i want to restrict the slider to a certain range.
Fr ex: my slider minvalue is 0 & maxvalue is 10000, but i can scroll only upto say 7000, my slider must move from 0 to 7000 but the range bar must be 10000. Is there any way to do this?
There is an event for the slider called OnClientDrag, what you can do is create a jquery/javascript function which will check the value upon changing and when it reaches 7000 you can cancel the event via a jquery method, something like this might help:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="Slider1" runat="server" AutoPostBack="false" style="right:0px" Text="0"/>
<ajaxToolkit:SliderExtender ID="SliderExtender1" runat="server"
BehaviorID="Slider1"
TargetControlID="Slider1"
Minimum="-100"
Maximum="100"
BoundControlID="Slider1_BoundControl"
Steps="5" />
<input id="btnDisable" type="button" value="Disable" onclick="disableSlider()"/>
<input id="btnEnable" type="button" value="Enable" onclick="enableSlider()" disabled="true"/>
<script type="text/javascript" language="javascript">
function disableSlider(){
$clearHandlers($find('Slider1')._handle);
$clearHandlers($find('Slider1')._railElement);
$get('btnDisable').disabled = true;
$get('btnEnable').disabled = false;
}
function enableSlider(){
$addHandlers($find('Slider1')._handle,
{
'mousedown': $find('Slider1')._onMouseDown,
'dragstart': $find('Slider1')._IEDragDropHandler,
'drag': $find('Slider1')._IEDragDropHandler,
'dragend': $find('Slider1')._IEDragDropHandler
},
$find('Slider1'));
$addHandlers($find('Slider1')._railElement,
{
'click': $find('Slider1')._onRailClick
},
$find('Slider1'));
$get('btnDisable').disabled = false;
$get('btnEnable').disabled = true;
}
</script>
</form>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.