I have an ASP.net WebForms page that has a lot of content on the top of the screen. It has a link button that will post back to the page and show another section of the page. When the page refreshes, I would like to set focus and scroll down to this section of the page.
I tried doing
txtField.Focus()
in my code behind and it will set focus and try to scroll there, but then scrolls right back to the top. The focus is still on my text box but the position of the screen is at the very top. The Link is at the top of the screen which is causing the postback. I want to scroll to the very bottom of the screen. It does this briefly and then scrolls right back to the top.
I have tried setting
Page.MaintainScrollPositionOnPostback = false;
but that doesn't seem to help either.
Is there some way I can force it to go to a specific position?
Is it possible to add an anchor tag to the URL when I postback using a button or link button?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…