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 8754021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:32:21+00:00 2026-06-13T13:32:21+00:00

I have two webpages written in asp.net, vb.net is code behind. When I click

  • 0

I have two webpages written in asp.net, vb.net is code behind. When I click on next button in one page the second page should appear. The second page is huge one, when I click on the next button, the page is coming, but its focus is bottom, in order to go top, I need to use the scrolling, what I want is to make the focus top.

  • 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-06-13T13:32:22+00:00Added an answer on June 13, 2026 at 1:32 pm

    You can use this script so that your page will be scrolled to a specific control on your page.

    The code should be put in your CodeBehind.
    Just choose some control which is at the top of your page and it should do the work..

    I should note that having your page scroll to the bottom is an unusual behavior and shouldn’t be happening by default. You should probably check why it’s happening in the first place.

    Update:

    Updated the code since the method used there is obsolete…

    private void FocusControlOnPageLoad(string ClientID)
    {
    
                ClientScript.RegisterClientScriptBlock(this.GetType(), "FocusOnControl",
    
                @"<script> 
    
                  function ScrollView()
    
                  {
                     var el = document.getElementById('" + ClientID + @"')
                     if (el != null)
                     {        
                        el.scrollIntoView();
                        el.focus();
                     }
                  }
    
                  window.onload = ScrollView;
    
                  </script>");
    
    }
    

    Usage:

    protected void Page_Load(object sender, EventArgs e)
    {
        FocusControlOnPageLoad(yourcontrol.ClientID); 
    }
    

    Equivalent VB.Net: (Thanks to @Mahyar)

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        FocusControlOnPageLoad(yourcontrol.ClientID)
    End Sub
    Private Sub FocusControlOnPageLoad(ByVal ClientID As String)
        Dim script As String = _
            "<script>" + _
                "function ScrollView()" + _
                "{" + _
                    "var el = document.getElementById('" + ClientID + "')" + _
                    "if (el != null)" + _
                    "{" + _
                    "el.scrollIntoView();" + _
                    "el.focus();" + _
                    "}" + _
                "}" + _
                "window.onload = ScrollView;" + _
            "</script>"
        ClientScript.RegisterClientScriptBlock(Me.GetType(), "FocusOnControl", script)
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two textboxes on an asp.net webpage, either one or both are required
I have a wicket page , which contains two Spring-managed beans , one is
I have two functions written in VB.NET: 1) The first function (call it GetValues())
I have two webpages, the one that you fill the information and another that
I had created a webpage using asp.net mvc3 razor. I have two master pages
I need to integrate two ASP.NET sites user-wise. I have a Web Pages ASP.NET
i have one login.jsp web page where i have two textboxes for username and
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two classes (MVC view model) which inherits from one abstract base class.
I have a classic asp webpage written in vbscript that outputs the results from

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.