Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6070153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:54:04+00:00 2026-05-23T09:54:04+00:00

I am writing in asp.net c# code. I want to control the page position

  • 0

I am writing in asp.net c# code.

I want to control the page position on a post back. Neither MaintainScrollPositionOnPostback equal true or false, is what I want. True is too low and False is too high. Another problem is that the position should be different depending on which control is press. A third issue is that MaintainScrollPositionOnPostback=true works in I.E. but not in Firefox.

Want I want is similar to the href related tags e.g. <a href="#body2"> except in code.

Thanks for any suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:54:04+00:00Added an answer on May 23, 2026 at 9:54 am

    Assuming you are able to use JQuery, try the following:

    http://abeautifulsite.net/blog/2010/01/smoothly-scroll-to-an-element-without-a-jquery-plugin/

    Just inject script and pass the ID of the control that fired your postback event.

    If you cannot use jquery for some reason, here is a less elegant approach:

    http://clifgriffin.com/2008/10/14/using-javascript-to-scroll-to-a-specific-elementobject/

    Edit (Samples):

    Here is an example of straight html using the jquery method, presuming you have a script file named jquery.js in the same folder as the html page.

    <html>
    <head>
        <script type='text/javascript' src='jquery.js'></script>
        <script type='text/javascript'>
        $(document).ready(function() {
            $('html,body').animate({ 
                scrollTop: $('#scrollHere').offset().top 
                }, 0//increase for smooth, visible scroll
            );
        });
        </script>
    </head>
    <body>
    
    <div style='width:100px; height:1000px; background-color:red;'>
    top filler
    </div>
    
    <a id='scrollHere' href='#'>Scrolls to this element</a>
    
    <div style="width:100px; height:1000px; background-color:blue;">
    bottom filler
    </div>
    
    </body>
    </html>
    

    Here is an example of a client-side method that you can pass the “ClientID” property of any visible page control and it will register the javascript to scroll to the element on page load (assumes jquery is registered on the page and only registers one call per request):

    private void ScrollToControl(string controlId)
    {
        //scroll to button
        string script =
            "$(document).ready(function() {" +
                "$('html,body').animate({ " +
                    "scrollTop: $('#" + controlId + "').offset().top " +
                "}, 0);" +
            "});";
    
        if (!Page.ClientScript.IsStartupScriptRegistered("ScrollToElement"))
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ScrollToElement", script, true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing an ASP.NET custom control. In my custom control code, I find
I'm writing a web page in ASP.NET. I have some JavaScript code, and I
I was writing some ASP.NET control when I came to the scenario where I
I'm writing an ASP.net MVC3 application using Entity Framework Code First and SqlCe4. I
I am writing a class for an ASP.NET MVC menu. I want to be
I have a asp.net page I'm writing and I'm perplexed by this problem. I
I'm writing an asp.net site (actually, a DotNetNuke module), using C#. From code-behind, I'm
I'm working with ASP.NET MVC3 using EF and Code First. I'm writing a simple
Instead of writing my ASP.NET C# applications in Visual Studio, I used my favorite
I'm currently writing an ASP.Net app from the UI down. I'm implementing an MVP

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.