Custom validator scrolls page to the top in ASP.NET
If we add a ValidationSummary control to the page, its ValidationSummaryOnSubmit function invokes “window.scrollTo(0,0)” when page is invalid. That’s why the page scrolls to the top.
To workaround this issue, we can assign a function to window.scrollTo which do nothing, so that window.scrollTo(0,0) will not take effect. This workaround is appropriate for the pages which doesn’t need window.scrollTo. For example, I have posted the following code for your reference. Hope it is helpful to you.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function check(source, args)
{
if (args.Value == "a")
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
window.scrollTo = function(){}
</script>
</head>

Comment (1)
Whoa this weblog is fantastic I love studying your articles. Stay up the great work! You realize, lots of individuals are hunting around for this information, you could help them greatly.