title: Scroll to end of page after loading gridview
body: <p>I have the following code at the end of my aspx page. When I click on the button below, the usercontrol loads a grid. The problem is that when that grid is loaded it's out of the viewed range, and the user has to scroll to the botton to view the displayed grid. </p>
  
  <pre><code>&lt;asp:UpdatePanel runat="server"&gt;
      &lt;ContentTemplate&gt;
          &lt;div style="border: thin; border-style: double"&gt;
              &lt;asp:Panel ID="PnlRequired" runat="server" DefaultButton="BntOpenGridView_Click"&gt;
                  &lt;table style="width: 100%"&gt;                 
                  &lt;tr width="100%"&gt;
                      &lt;td&gt;                            
                          &lt;asp:ImageButton ID="BtnOpenGridView" Visible="false" OnClick="BntOpenGridView_Click" runat="server" ImageUrl="~/Images/find1.png" Width="2.5%" /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;    
                  &lt;tr&gt;
                      &lt;td&gt;    
                          &lt;UserControl:RequiredGridView runat="server" ID="RqGrdView"&gt;&lt;/UserControl:KeywordsGridView&gt;
                      &lt;/td&gt;    
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;asp:Label ID="lblErrorMessage2" runat="server" ForeColor="Red"&gt;&lt;/asp:Label&gt;                       
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;/asp:Panel&gt;              
          &lt;/div&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>What I'm trying to do is to use javascript some way to scroll to the bottom of the page after displaying the grid. 
  Here's what i've tried: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function ScrollToGrid()   
      {
           document.getElementById('RqGrdView').scrollIntoView(true);
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>In the Button Click event after triggering the usercontrol to load the gridview I added the following code: </p>
  
  <pre><code>ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "focusOnGrid", "ScrollToKeywordsGridView()", true);
  </code></pre>
  
  <p>This didn't work</p>
  
  <p>I also tried to add the same code to Page PreRender as follows: </p>
  
  <pre><code>protected void BntOpenGridView_Click(object sender, ImageClickEventArgs e)
  {
        isRequiredGridViewClicked = true;
        // code to load gridview in usercontrol                
  }
  
  protected override void OnPreRender(EventArgs e)
  {
        base.OnPreRender(e);
        if (isRequiredGridViewClicked)
        {
             ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "focusOnGrid", "ScrollToGridView()", true);
             isRequiredGridViewClicked = false;
        }
  }
  </code></pre>
  
  <p>This also didn't work, the javascript fires OK, but the gridview is not not displayed in full and the user has to scroll manually. </p>