Qadeer Qadeer - 9 months ago 59
ASP.NET (C#) Question

how to scroll a page at specific position when page reloads in MVC ASP.NET

This is ASP.NET MVC project, I have placed a

at specific position in the page and added id
. When this page loads or reloads normally it behaves as normal, but when a specific button is clicked I want that page after completing all postback progress when page loads done, it comes to the position of that div.

with java script I tried this, but did nothing any solution from server side or client side will be appreciable.

$(".button-1").click(function () {
if (localStorage && !localStorage.getItem('click')) {
localStorage.setItem('click', true);

$(document).ready(function () {
if (localStorage.getItem('click') == true) {

window.location = window.location.href + "#dealProductAnchor";
//click = false;


If you want to Achieve this via BackEnd you Can set a value into ViewBag and check it on .cshtml page like below:

Controller Code :

 public ActionResult TextAction() {
// Do your Logic here
        ViewBag.testValue = "test";
        return View();

JavaScript Code:

$(document).ready(function () {
@if (ViewBag.testValue == "test") {
            scrollTop: ($("#dealProductAnchor").offset().top) - 200
        }, 'slow');</text>

hope it helps you :)