【问题标题】:Strange scrollbar behavior with jQuery-validationjQuery-validation 的奇怪滚动条行为
【发布时间】:2012-08-24 19:36:57
【问题描述】:

当我单击“添加依赖”链接按钮时,我希望滚动条滚动到底部,这很有效。 问题是在回发后选择添加相关链接按钮时,文本“请修复以下问题:”会显示一秒钟。但是,它下面没有错误消息。验证(jQuery-validation 插件)如果存在验证问题,则可以正常工作。

谢谢。

这里是相关的asp.net代码:

<script type="text/javascript" language="javascript">
    function toBottom(id) {
        document.getElementById(id).scrollTop = document.getElementById(id).scrollHeight
    }

</script>
<div id="divscroll" class="scroll">

</div>

<div id="validationMessageContainer" class="error" >
    <span id="info_dep_fix_problemls">Please fix the following problems:</span>
    <ul></ul>
</div> 

<asp:LinkButton ID="AddDependent" Text="Add Dependent" CssClass="btngeneral" OnClientClick="toBottom('divscroll')"
            OnClick="AddDependent_Click" runat="server" />&nbsp;&nbsp;

背后的C#代码:

protected void AddDependent_Click(object sender, EventArgs e)
{
    //Other unrelated code  -- the button has to be server side as we do database connections, etc.
getScrollPosition();
}

protected void getScrollPosition()
    {
        //Sets the scroll position of the divscroll to the bottom on postback
        ClientScript.RegisterStartupScript(this.GetType(), "toBottom", "toBottom('divscroll')", true);
    }

这是滚动 div 的 css。

div.scroll
{
    -ms-overflow-x:hidden; 
    overflow-x:hidden; 
    -ms-overflow-y:auto; 
    overflow-y:auto; 
    max-height: 400px;
    max-width: 900px;
}

【问题讨论】:

  • 我不清楚你的问题是什么......
  • 点击 AddDependent 按钮时,会显示 jQuery 验证错误标题。没有要验证的数据,它很快就会消失,但它的出现很烦人。谢谢。
  • 我周末回家了,我会在星期一回来查看任何建议。
  • 刚刚注意到,由于某种原因,上面代码中的“请”以蓝色突出显示,而它应该像字符串的其余部分一样是黑色的。

标签: c# javascript asp.net css jquery-validate


【解决方案1】:

我们想通了,将style="display:none" 添加到validationMessageContainer div 中,修复了它。

感谢所有帮助过的人。

【讨论】:

    【解决方案2】:

    尝试在 JavaScript 的末尾添加一个 return false;或者可能是从后面的代码中出现的?目前还不清楚。你的意思是jquery验证插件?如果是表单验证器,请查看插件代码。

    【讨论】:

    • 这是评论,不是问题的答案。
    • 我尝试添加“return false;”到javascript,它没有改变任何东西......
    • 如果可能,请尝试检查它在更新面板中的显示方式。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-28
    • 1970-01-01
    • 2015-09-08
    • 2016-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多