开发者

Highlighting HTML table when a link in the table is clicked

开发者 https://www.devze.com 2023-02-22 00:19 出处:网络
I have a lengthy asp.net page. A HTML table in the page has a link. when the link is clicked the page refreshes and takes me to the top part of the page. Instead, i want to see the part of the page th

I have a lengthy asp.net page. A HTML table in the page has a link. when the link is clicked the page refreshes and takes me to the top part of the page. Instead, i want to see the part of the page that has the link. It should automatically scroll down to that part once the page refreshes. How is that possible.

Rea开发者_Go百科lly appreciate your help. Thank you!


Add MaintainScrollPositionOnPostBack="True" in the page directive.


If you're using ASP.NET 2.0 or above, and that is a LinkButton doing a postback, you can use:

<%@ Page MaintainScrollPositionOnPostback="true" %>


To color a row you can do this by using HtmlAgilityPack and by using a unique ID per table row, you can do:

HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);

var rows = doc.DocumentNode.SelectNodes("tr");
var linkRow = rows.FirstOrDefault(node =>
{
    HtmlAttribute a = node.Attributes["id"];
    if (null == a) return false;
    return "idLookingFor" == a.Value;
});
linkRow.Attributes.Add("bgcolor", "red"); 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号