【问题标题】:Getting error while using Jquery Slider?使用 Jquery Slider 时出错?
【发布时间】:2012-02-29 10:02:53
【问题描述】:

在我的带有母版页的 aspx 页面中使用 jquery 滑块时,出现类似

的错误
 The state information is invalid for this page and might be corrupted.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The state information is invalid for this page and might be corrupted.

我的代码是

<div class="demo">
    <input type="text" class="sliderValue"  />
        <p>
        </p>
        <div id="slider"></div>
    </div>

<script language="javascript">
        $("#slider").slider({
            range: "min",
            value: 1,
            step: 10,
            min: 0,
            max: 1000,
            slide: function (event, ui) {
                $("input").val(ui.value);
            }
        });


        $("input.sliderValue").change(function (event) {
            var value1 = parseFloat($("input").val());
            var highVal = value1 * 2;
            $("#slider").slider("option", { "max": highVal, "value": value1 });
        });
    </script>

有什么建议吗??

编辑: 但是这段代码在另一个 aspx 页面中运行良好。请问我知道这背后的原因

  <div>
  <input type="text" class="sliderValue" data-index="0" value="10" runat="server" />
  <input type="text" class="sliderValue" data-index="1" value="90" runat="server" />
  </div>
  <br />
  <div id="slider">
  </div>

<script language="javascript">
        $(document).ready(function () {
            $("#slider").slider({
                min: 0,
                max: 100,
                step: 1,
                range: true,
                values: [10, 90],
                slide: function (event, ui) {
                    for (var i = 0; i < ui.values.length; ++i) {
                        $("input.sliderValue[data-index=" + i + "]").val(ui.values[i]);
                    }
                }
            });

            $("input.sliderValue").change(function () {
                var $this = $(this);
                $("#slider").slider("values", $this.data("index"), $this.val());
            });
        });

    </script>

【问题讨论】:

  • 您提到的范围:“min”错误。它应该是一个布尔值。您应该指定真/假。还要检查您提到的值属性是否正确。
  • 这看起来像是服务器错误,可能与jquery无关。我建议将有问题的页面放在网上,并分享链接。我猜该错误与代码隐藏或您未包含在上述 sn-ps 中的其他内容有关。
  • 问题似乎出在页面的视图状态,要么超出其最大长度,要么可能是其他原因,您可以尝试将页面的视图状态设置为 false 以确保是否这是否是原因
  • 看看这个链接可能会有所帮助social.msdn.microsoft.com/Forums/sv-SE/netfxbcl/thread/…

标签: jquery asp.net jquery-ui jquery-ui-slider


【解决方案1】:

尝试将您的代码包装在 $(document).ready(function(){});

<script language="javascript">

$(document).ready(function(){

        $("#slider").slider({
            range: "min",
            value: 1,
            step: 10,
            min: 0,
            max: 1000,
            slide: function (event, ui) {
                $("input").val(ui.value);
            }
        });


        $("input.sliderValue").change(function (event) {
            var value1 = parseFloat($("input").val());
            var highVal = value1 * 2;
            $("#slider").slider("option", { "max": highVal, "value": value1 });
        });

});
    </script>

【讨论】:

    【解决方案2】:

    使用这个,希望对你有帮助

    1. 在产生错误的文件顶部添加“Debug=true”指令。示例:
     <%@ Page Language="C#" Debug="true" %>
    

    或:

    2) 将以下部分添加到您的配置文件中 应用:

    <configuration>    <system.web>
         <compilation debug="true"/>    </system.web> </configuration>
    

    我已经使用了您的代码,并且没有收到您所说的任何错误。

    【讨论】:

    • 使用我的代码在你的机器上试一下,不管它是否工作
    猜你喜欢
    • 2012-02-04
    • 1970-01-01
    • 1970-01-01
    • 2016-08-12
    • 2014-03-31
    • 2015-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多