【发布时间】: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" />
背后的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