单击按钮向下滚动并关注 table 行

scroll down and focus on table row on click of button

我有一个 table,其中有 75 行,每行都有一个按钮。当我点击某一行的按钮时,它会显示一些结果并且页面会刷新。我们需要向下滚动并查看结果。有什么方法可以滚动并聚焦到我们单击按钮的特定行吗?

您可以将此代码添加到 asp.net 文件的 header 中:

 MaintainScrollPositionOnPostback="true"

喜欢:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" MaintainScrollPositionOnPostback="true" Inherits="WebApplication1._Default" %>

我们可以在按钮上使用Anchor标签。

<a href="#someName" id="someID" runat="server"><asp:Button ID="btnID" Text="MoreInfo" runat="server"/></a>

然后使用锚标签id和焦点。

someID.focus()

它将集中在我们单击按钮

的table行