0

我需要禁用MultiHandleSliderExtender. 我在这里找到了禁用 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);     

}
4

1 回答 1

0

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

于 2013-08-20T09:18:36.330 回答