![](/img/trans.png)
[英]I am unable to submit the form due to the jquery-validation alert in ASP.NET Core 6.0
[英]Strange scrollbar behavior with jQuery-validation
当我单击“添加从属”链接按钮时,我希望滚动条滚动到底部,这是可行的。 问题是当回发后选择“添加从属”链接按钮时,文本“ 请解决以下问题: ”显示一秒钟。 但是,它下面没有错误消息。 如果存在验证问题,则验证(jQuery验证插件)可以正常工作。
谢谢。
这是相关的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;
}
我们弄清楚了,将style="display:none"
到validationMessageContainer
div中,对其进行了修复。
感谢所有提供帮助的人。
尝试在JavaScript的末尾添加return false; 或从代码后面出现的maby? 目前尚不清楚。 你的意思是jQuery验证插件? 如果是有效的表单,请查看插件代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.