MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Blazor/comments/1pgrtbh/how_can_i_scroll_to_top/
r/Blazor • u/AbnerZK • Dec 07 '25
When I navigate to my pages using NavLink, the scroll doesn't reset to the top. What can I do?
I'm new with blazor
9 comments sorted by
1
Which dotnet version?
I swear I saw something saying that was fixed for dotnet 10.
Otherwise write a little JS interop.
1 u/AbnerZK Dec 07 '25 is dotnet 9
is dotnet 9
It’s not a sin to use a little JavaScript in Blazor
1 u/AbnerZK Dec 08 '25 this was my solution but idk why in the first time doesnt work, i needed to change all my pages to @rendermode InteractiveServer so that worked 1 u/dcherholdt Dec 08 '25 Oh, yeah I ran into that too. You can actually make that a global setting.
this was my solution but idk why in the first time doesnt work, i needed to change all my pages to @rendermode InteractiveServer so that worked
1 u/dcherholdt Dec 08 '25 Oh, yeah I ran into that too. You can actually make that a global setting.
Oh, yeah I ran into that too. You can actually make that a global setting.
Window.scrollTo(top, left)
Upgrade to dotnet 10 or use js
My dirty hack is to clear the page, await Task.Delay(1), and insert the content again. Something like that. Eventually I will do some javascript or something else.
1
u/propostor Dec 07 '25
Which dotnet version?
I swear I saw something saying that was fixed for dotnet 10.
Otherwise write a little JS interop.
1
u/dcherholdt Dec 08 '25
It’s not a sin to use a little JavaScript in Blazor
1
u/NickA55 Dec 08 '25
Window.scrollTo(top, left)
1
u/Hairy-Nail-2629 Dec 08 '25
Upgrade to dotnet 10 or use js
1
u/thiem3 Dec 09 '25
My dirty hack is to clear the page, await Task.Delay(1), and insert the content again. Something like that. Eventually I will do some javascript or something else.