0

I want to the page to scroll to the item where a condition is met. I have learned how to use this (which worked for client side tags) :

ClientScript.RegisterStartupScript(this.GetType(), "hash", "location.hash = '#c66';", true);

But I could not scroll to specific Item. I tried to change ID of a hiddenfield inside the itemtemplate on _ItemDataBound() event but still not working. What should I do ?

I've spend most of my day searching for this.

Omranovic
  • 45
  • 7

1 Answers1

0

I strongly recommend to do this by using JavaScript, because using server-side code to do this will render auto-generated client-side code and may be less understandable.

Here is a question that will help to do it using jQuery, using the id of the tag generated. You may do this using either id, CSS class, data-attribute, etc. jQuery scroll to element

Besides, if you want to do it using the id, you may need this other info to render the final id that you can see in the browser, since this differs a lot from the one you code in the *.aspx file. Webforms and jQuery, how to match the ID's?

Community
  • 1
  • 1
Alberto Cruz
  • 125
  • 3
  • 9
  • I am talking about repeater here, so it has be done in server side. These links are completely useless. – Omranovic Jun 26 '16 at 23:08
  • A repeater is just a control that foreaches a list and render what you are putting inside it. You can still do it using JavaScript and, as far as I am concerned, this is still the best practice. However, you should do the most mantainable solution for your current project. Sorry for not giving the answer you were expecting :) – Alberto Cruz Jun 27 '16 at 13:57
  • Well sorry if my reply seemed rude but i really wasted my whole day on this. I gonna try this again.. – Omranovic Jun 27 '16 at 15:40