0

I am using an ASP GridView. Each row has a unique ID like this: <tr id="abc123">

When this page is visited, I may get the ID from session or query string in Page_Load(). If I find the ID, I need to scroll to the specific row.

I cannot use AJAX or jQuery because it is a legacy application. There are few solutions I have found but they are depending on jQuery/AJAX/Bootstrap etc. For example, this or this. This is not a postback, so I cannot use MaintainScrollPositionOnPostback.

Farhan
  • 2,535
  • 4
  • 32
  • 54
  • Have you considered using a [URI fragment](https://en.wikipedia.org/wiki/URI_fragment) like `https://www.example.com/thispage#abc123`? – Andrew Morton Jul 08 '20 at 15:02
  • 1
    Is JavaScript allowed? [ScrollIntoView](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) is supported in all browsers nowadays and you could render the relevant script at the end of the page. – Andrew Morton Jul 08 '20 at 15:18
  • @AndrewMorton My URL is coming like `https://www.example.com/thispage.aspx?SomeID=abc123` I can change it to what you are suggesting. The issue is on the page when trying to take the scroll action. I am retrieving SomeID in `Page_Load()`. – Farhan Jul 08 '20 at 17:39
  • Which means you could also emit some JavaScript to call {element}.scrollIntoView() - @AndrewMorton has the right idea – sh1rts Jul 08 '20 at 21:42

0 Answers0