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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:52:11+00:00 2026-05-24T02:52:11+00:00

I am working on an ASP.NET application where I have 3 user controls embedded

  • 0

I am working on an ASP.NET application where I have 3 user controls embedded in an aspx page which in turn uses a master page.

2 Usercontrols out of the 3 have a DataList. I would like to scroll to a specific / selected DataListItem in the usercontrol.

Also, I looked at this thread (http://forums.asp.net/t/1596201.aspx). But I don’t think it will work in my case. And I have MaintainScrollPositionOnPostback=”true” in the aspx page – No luck still.

It would be really helpful, if someone could help me figure out a way to do this

The markup looks something like this

     <asp:DataList ID="dl" runat="server"
            SkinID="DataList" onitemcommand="dl_ItemCommand" 
            >
            <ItemTemplate>
                <asp:Label ID="lblIDTitle" runat="server" Text="ID: " />
                <asp:Label ID="dlLabel" runat="server" Text='<%# Eval("Id") %>'  />
                <asp:LinkButton ID="btnSelect" runat="server" CommandName="Select">Select</asp:LinkButton>
                <br />
                <asp:Label ID="NameLabel" runat="server" Text='<%# Eval("DisplayName") %>' />
                <br />
            </ItemTemplate>
        </asp:DataList>
  • 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-24T02:52:12+00:00Added an answer on May 24, 2026 at 2:52 am

    Looks like it is pretty simple. Here are the steps:

    • In the user control containing the datalist, added this method..

       public void FocusControlOnPageLoad(string ClientID, System.Web.UI.Page page)
       {
           ClientScriptManager clientScript = this.Page.ClientScript;
           clientScript.RegisterClientScriptBlock(this.GetType(),"CtrlFocus",
      
                          @"<script> 
      
                function ScrollView()
      
                {
                   var el = document.getElementById('" + ClientID + @"')
                   if (el != null)
                   {        
                      el.scrollIntoView();
                      el.focus();
                   }
                }
      
                window.onload = ScrollView;
      
                </script>");
      
      } 
      
    • As you can see from the mark-up I had a linkbutton. So with the OnItemCommand, I called this function whenever the link button was clicked. Something like this;

      protected void dlCommitment_ItemCommand(object source, DataListCommandEventArgs e)
      {            
          if (e.CommandName == "Select")
          {  
              LinkButton link = LinkButton)dlCommitment.Items[e.Item.ItemIndex].FindControl("btnSelectCMTMT");
               FocusControlOnPageLoad(link.ClientID, this.Page);
          }
      }
      

    And it worked like a charm. Thanks to a post that discussed about ScrollIntoView and a code project article about the method I have posted above. Since I’m on a rush, I’m not able to attach the links. Thanks to the ones who posted this information originially.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working with an ASP.NET MVC application. I have one master page having
I have created a Web Application in asp.net 2.0. which is working fine on
I am working on an asp.net/C# web application, In the main page: I have
Currently, I have a ASP.net 3.5 web application for which I currently am working
I am working on an asp.net web application which uses a fair bit of
I have an ASP.NET application I am working on. One of the requirements of
Good Morning, I'm working on an ASP.NET 3.5 webforms application and have written the
I'm currently working on web application using VB in ASP.NET. Right now I have
I have one sharepoint custom page application which is rendering from a user control.
I'm working on an asp.net application that allows the user to update data for

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.