如何在Ajaxtoolkit中禁用MultiHandleSliderExtender

时间:2013-08-19 11:51:17

标签: c# asp.net ajaxcontroltoolkit

我需要停用MultiHandleSliderExtender。我在Here找到了禁用Slider的答案。我试图修改我在那里提到的代码。但是MultiHandleSliderExtender它没有用。

<form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="Server" />
        <div>

            <table>
                <tr>
                    <td>
                        <asp:TextBox ID="multiHandle2_1_BoundControl" runat="server" Width="30" Text="0" />
                    </td>
                    <td style="width: 180px">
                        <asp:TextBox ID="sliderTwo" runat="server" />
                        <ajaxToolkit:MultiHandleSliderExtender ID="multiHandleSliderExtenderTwo" runat="server"
                            BehaviorID="multiHandleSliderExtenderTwo"
                            TargetControlID="sliderTwo"
                            Minimum="0"
                            Maximum="10"
                            Length="175"
                            TooltipText="{0}"
                            EnableHandleAnimation="true"
                            Orientation="Horizontal"
                            EnableKeyboard="false"
                            EnableMouseWheel="false"
                            ShowHandleDragStyle="true"
                            ShowHandleHoverStyle="true">
                            <MultiHandleSliderTargets>
                                <ajaxToolkit:MultiHandleSliderTarget ControlID="multiHandle2_1_BoundControl" />
                                <ajaxToolkit:MultiHandleSliderTarget ControlID="multiHandle2_2_BoundControl" />
                            </MultiHandleSliderTargets>
                        </ajaxToolkit:MultiHandleSliderExtender>
                        <asp:Label ID="lbl" runat="server" Text="1" />
                    </td>
                    <td>
                        <asp:TextBox ID="multiHandle2_2_BoundControl" runat="server" Width="30" Text="10" />
                    </td>
                </tr>
            </table>
            <input id="btnDisable" type="button" value="Disable" onclick="disableSlider()" />
            <input id="btnEnable" type="button" value="Enable" onclick="enableSlider()" disabled="true" />
        </div>

        <script type="text/javascript" language="javascript">
            function disableSlider() {
                $clearHandlers($find('multiHandleSliderExtenderTwo')._handleData);
                //$clearHandlers($find('multiHandleSliderExtenderTwo')._railElement);
                $get('btnDisable').disabled = true;
                $get('btnEnable').disabled = false;
            }

    function enableSlider() {
        $addHandlers($find('multiHandleSliderExtenderTwo')._handleData,
           {
               'mousedown': $find('multiHandleSliderExtenderTwo')._onMouseDown,
               'dragstart': $find('multiHandleSliderExtenderTwo')._IEDragDropHandler,
               'drag': $find('multiHandleSliderExtenderTwo')._IEDragDropHandler,
               'dragend': $find('multiHandleSliderExtenderTwo')._IEDragDropHandler
           },
           $find('Slider1'));

        //$addHandlers($find('multiHandleSliderExtenderTwo')._outer,
        //    {
        //        'click': $find('multiHandleSliderExtenderTwo')._onRailClick
        //    },
        //    $find('multiHandleSliderExtenderTwo'));
        $get('btnDisable').disabled = false;
        $get('btnEnable').disabled = true;
    }

        </script>
    </form>
multihandler中的

没有名为railElement的事件。有没有相当于这个?或任何其他禁用控制的想法都会有所帮助

编辑:我可以禁用此功能。但是在启用时会出现问题。

我按如下方式修改了我的代码:

function disableSlider() {           
    $clearHandlers($find('multiHandleSliderExtenderTwo')._handleData);
    $clearHandlers($find('multiHandleSliderExtenderTwo')._outer);
    $clearHandlers($find('multiHandleSliderExtenderTwo')._outerDelegates);     

}

1 个答案:

答案 0 :(得分:0)

无需使用java脚本进行禁用。最简单的方法是将MultiHandleSliderExtender - IsReadOnly属性设置为true。