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

  • Home
  • SEARCH
  • 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 6008605
In Process

The Archive Base Latest Questions

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

My ASP.Net application generates an <asp:Table> from the codebehind. What I need is for

  • 0

My ASP.Net application generates an <asp:Table> from the codebehind. What I need is for the header row of that table to slide down the page as the user scrolls past it.

I’ve tried the following approach using JavaScript:

window.onscroll = function () {

    //grab the current scroll position
    var scrollY = document.body.scrollTop;
    if (scrollY == 0) {
        if (window.pageYOffset)
            scrollY = window.pageYOffset;
        else
            scrollY = (document.body.parentElement) ? document.body.parentElement.scrollTop : 0;
    }

    //grab the position of the header row I want to slide
    var head = $("tr[name='headerrow']").offset();
    var headtop = head.top;
    var headleft = head.left;

    //if the user has scrolled past the top of the header row
    if (scrollY > headtop) {

        //code correctly reaches this point as alerts show
        //alert('got here');

        //position the header row to the same as the scroll position 
        $("tr[name='headerrow']").offset({ top: scrollY, left: headleft });
    }
}

I can’t get the row to move. There are no error message to be seen on the various browsers developer tools.

Any help would be appreciated.

EDIT: I tried calling the offset() function on the children of the row (i.e. all of the <th> elements) like this:

$("tr[name='headerrow']").children().offset({ top: scrollY, left: headleft });

This now works but of course, they’re all pushed over to the left because I’m using the left value of the header row itself… I’ll keep this updated with my progress but in the meantime any assistance is appreciated as always.

  • 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-23T01:50:54+00:00Added an answer on May 23, 2026 at 1:50 am

    Solution:

    Use the children() method on the table row to allow you to change the offset of each of the <th> elements. The left value can be omitted from the offset() method, i.e.

    $("tr[name='headerrow']").children().offset({ top: scrollY });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an ASP.NET application that manages it's own User, Roles and Permission database
When an ASP.NET application errors out and generates the yellow-screen display, I'd like to
Simple ASP.NET application. I have two drop-down controls. On the first-drop down I have
The ASP.NET application that I am currently responsible for at my day job has
I have a ASP.NET application that we've written our own logging module for. My
I have an ASP.net Application that runs on the internal network (well, actually it's
I have a Silverlight application that communications with an ASP.NET backend through WCF. I
I'm converting an app from ASP.NET WebForms to WinForms. There is one asp.net page
I have an ASP.Net webforms application that uses the .Net globalization features to deliver
I'd like to execute an exe from an ASP.NET MVC application. Yes I understand

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.