Scroll to bottom of page after server control validation




 /* Style Definitions */
	{mso-style-name:"Table Normal";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-fareast-font-family:"Times New Roman";

Hello All,


I developed a WepApp, it fills a GridView on PageLoad event, the grid view is quite big, it has a ‘select’ button on each row.

When a user clicks on that button, it connects to a Database and gets additional information, then fills some textboxes/labels/radio buttons( all running at server) and shows a panel with all those controls at the very bottom of the page(below GridView).


Since most of the times the gridview shows more than 100 rows… I’d like to send the browser to the bottom of the page on that select-button-click event after database connection has finished… due to policies I cannot set pages to Gridview or use AJAX…


I tried using javascript


function jumpScroll() {

        window.scroll(0,150); // horizontal and vertical scroll targets



But I do not know where to declare this function and how to call it after the user clicks on the select button..



5/1/2009 6:10:02 PM 24353 articles. 1 followers. Follow

10 Replies

Similar Articles

[PageSpeed] 48

 Make your own Select command (link or button) and add the javascript as an attribute or use the ClientClick event which is built-in to the server button control.

You can also use the anchors ... just add an invisible link to the bottom of the page 

<a name="target">&nbsp;</a> 


then just assing it to the select links e.g.


< a h ref="# target" >Select</a>  


Hope this Helps

When you ask a question, remember to click "Mark As Answer" when you get a reply which answers your question.
5/4/2009 11:11:32 AM

Just append this code after your code of select button click.

 Page.ClientScript.RegisterStartupScript(GetType(),"myscript" "<script>window.scroll(0,150);</script");

5/4/2009 11:19:17 AM

 Or use the RowCreated event handler. Just add this line there:

CType(e.Row.FindControl("btnName"), Button).Attributes.Add("onclick", "<script>window.scroll(0,150);</script>")


// C# .NET
((Button)e.Row.FindControl("btnName")).Attributes.Add("onclick", "<script>window.scroll(0,150);</script>");

When you ask a question, remember to click "Mark As Answer" when you get a reply which answers your question.
5/4/2009 11:29:14 AM

Add this JavaScript to the markup (aspx file)

<script type="text/javascript">
function windowOnLoad()
 var isPostBack = (('<%= IsPostBack %>').toLowerCase() == 'true') ? true : false;

 if ( isPostBack == true )

window.onload = windowOnLoad;
// -->


5/4/2009 11:39:19 AM

little modification.

instead of


CType(e.Row.FindControl("btnName"), Button).Attributes.Add("onclick", "<script>window.scroll(0,150);</script>")




CType(e.Row.FindControl("btnName"), Button).Attributes.Add("onclick", "window.scroll(0,150);")
but i don't think this will solve the purpose, coz with this code his page will scroll first and then postback 
wheras he wants that it should scroll after it returns from the postback. 

5/4/2009 11:40:00 AM

 Hi gigologio23,


due to policies I cannot set pages to Gridview or use AJAX…


As far as I understood your problem, it's quite easy to solve your problem.

Just set Me.MaintainScrollPositionOnPostBack = True in your page load.

It will work as you are not using AJAX.

Please mark as Answer if it helps u. Thanks!

Parth Patel
Techsture Technologies
Software Developer
5/4/2009 11:55:44 AM

Moreover, if you want to put GridView inside scrollable div and want to maintain scroll position of scrollable div then refer the following code. It store the current position of div in hidden html input and then retrieve it on postback.


&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""&gt;
<html xmlns="" >
<head runat="server">
<title>Maintain Scroll Position</title>
<script type="text/javascript">
function SaveScrollPosition(obj)
document.getElementById('hdnScrollPosition').value = obj.scrollTop;
function ScrollMove(objId)
document.getElementById(objId).scrollTop = document.getElementById('hdnScrollPosition').value;
<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' If page is full post back then this will maintain scroll position
Me.MaintainScrollPositionOnPostBack = True

Page.IsPostBack Then
current As ScriptManager = ScriptManager.GetCurrent(Me.Page)
If current IsNot Nothing AndAlso current.IsInAsyncPostBack Then
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "__ScrollPos", ";ScrollMove('divOuter');", True)
ClientScript.RegisterStartupScript(Me.GetType(), "
__ScrollPos", ";ScrollMove('divOuter');", True)
End If
End If
End Sub

<form id="
form1" runat="server">
<asp:PlaceHolder ID="
phTable" runat="server"></asp:PlaceHolder>
<asp:ScriptManager ID="
objScriptManager" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="
objUpdatePanel" runat="server">

<input type="
hidden" id="hdnScrollPosition" runat="server" value="0" />
<div style="
height:70px;overflow:auto" id="divOuter" onscroll="SaveScrollPosition(this);">
<%-- Assume GridView is inside this Div --%>
<br /><br /><br /><br /><br /><br /><br /><br />
<input type="
submit" id="btnTest" runat="server" value="test" />
<br /><br /><br /><br /><br /><br /><br /><br />

Please mark as Answer if it helps u. Thanks!

Parth Patel
Techsture Technologies
Software Developer
5/4/2009 11:59:20 AM

coool has got the perfect point, just decorate your page header this way

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Testing.aspx.cs" Inherits="Testing" MaintainScrollPositionOnPostback="true" %>

5/4/2009 12:03:09 PM

Hi Friends,

I dont think that

window.scroll(0,150)  will solve your query.

because in first case it just scrolls the page from top to 150th height. (in your case the height may vary). It is not appropriate even if achieved in one of the case.

What i say is

1) take a link as if   
<asp:LinkButton runat="server" ID="btn" OnClientClick="window.location.href= '#mycontrol'" Text="Select"></asp:LinkButton> 
 in the row where you would like to select. And Add  <a name="mycontrol"></a> at the place where your contents would be 
displayed. This <a> tag wont shown any link on your page. 
2) Secondly add attribute MaintainScrollPositionOnPostback="true" in Page Directive (<@Page ...> )
In this way onclientclick you move to the required location and the page is postback. As the MaintainScrollPositionOnPostback is set true the page would maintain its scroll position before postback.
This will do your work.


Please Mark as Answer if this reply helps you :)
5/4/2009 12:36:48 PM

 Thanks Everyone.. I'm gonna try all this suggestions and will let you know what I found...


5/4/2009 10:47:51 PM

Similar Artilces:

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in ( required field, range validator and others) question is the required field validator is a server side control. So does that mean that it does a post back? it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

validation, is it better to have client side or use server side validator controls
 Hi All. I want to do validation on text boxes etc. Is it better to do client side validation or just use the server side validation controls?   Hi!  If for server side controls you mean RequiredFieldValidator, CompareValidator, RegularExpressionValidator, etc.. i can tell you that they use client and server validation. For instance if you use a RequiredFieldValidator, on the client will be a validation, but on the server this condition will be evaluated again. Probably one of the objetives of this is deal with client with javascript disabled. Of course I ...

Accessing server-side control in client-side javascript function; on Content page
I am trying to set an asp:textbox value in the Client side javascript function. It works fine on the standalone page. But when i try to do this the Content page, it’s giving the follwoing error message. document.getElementByID[...] is null of not an object  Any idea? Thanks, Riz   Hi, are you using ClientID property of that server control, to get its ID (which is rendered at the client and can be used with document.getElementById )?Thanks,Teemu KeiskiFinland, EU Thank you my problem is solved....

client side validation vs server side validation
hello  i see a web form that consists of three controls :textbox,requiredfieldvalidator that weired to the textbox and a button within the click event of the button there is the following: if page.isvalid then response.redirect("Page is valid") else response.redirect("Page is not valid") end if according to my understandings: when the user does not fill anything in the textbox and then clicks the button the the page will not be submitted (i.e no request to the page will be happened or no postback will be happened) then no server event will be happened so it is sure when the us...

Combining a server-side control with a client-side control!
Hi all, I am trying to combine a server-side control with a client-side control. I have created a listbox in both sides, the client-side control's code is: <select size="4" name="lstFruit" id="Select1" ondblclick="lst_dblClick" visible="false"> <option value="Banana">Banana</option> <option value="Apple">Apple</option> <option value="Mango">Mango</option> <option value="Orange">Orange</option> </select> The other one is the server-side control which has this code:   I wanted to add the ondblClick attribute to the se...

Server Side Validation vs Client Side Validation
If your page is using client side validation for required fields, expressions, etc.     What are the benefits or disadvantages of using 'extra' server side validation for max lengths, parsing, etc? Both have their Advantages and Disadvantages... so give this a read Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET hi there, advantage: because you are using javascript some browsers for any reason may not sup...

What are diff Server-side control and Client-side control ?
What are diff Server-side control and Client-side control ? and diff server -side coding and client -side coding ? please help I have answered the first part of your question in your previous posting. Server-side coding languages are ASP, ASP.NET, PHP, CGI (Perl) and many, many more. They are used to create dynamic web content (based on additional information that is attached to the request) and are often used to extract information from databases. Client-side coding languages are JavaScript, VBScript, EMACScript and are used to create dynamic content that responds to the u...

Server side validation affecting client side validation
Hi there I have some client side validation that is working fine and enables/disables buttons based on user selections. This works great. However, when I perform server side validation using custom validators (like checking if the user has entered < HTML > tags or decimals in the integer boxes) and the server side validation returns isValid = false then all of the JavaScript validation that I've already done when the user clicked each control is lost. I don't understand why the enabled/disabled state of the control is not maintained.  What is calling the JavaScr...

Client Side validation of Calendar control prior to server side selectionchanged event code
Hello, Any thoughts or suggestions regarding this will be greatly appreciated. I have a Calendar control with the validation constraint(can't enter appointments on Holidays or on Thursdays). To create a smoother experience, I'd like for this to be done client side. The dillema is how can I intercept or precede the <asp:calendar> controls selectionchanged event from firing and run my client javascript; passing it to the server if validation succeeds for more intensive processing and database activity. The clientside javascript will need the selected date to deter...

avoiding redundant server-side validation after client-side validation
I see an inaccurate validation behavior on my (2.0) form. The EnableClientScript property of my validation control is set to True by default, so it performs the validation on clientside. But as soon as this occurs, it also performs the server-side validation, so the page refreshes. When the validation error occurs on clientside, it should not do the validation on serverside (I'm not calling Page.Validate() or doing Page.IsValid). In my past experience, handled this automatically, but I guess it's not always the ca...

Is there a correspondance for each server side control to be equivalent to a client side html control
Where can find the list and can use that equivalence and what is its usage plsThanksThanks a lot, I appreciate your taking the time to help me. What exactly do you mean? A correspondence of what?All controls have a ClientID property, which for most controls tells the DOM element ID that will be used in the HTML rendering. Aside from that certain controls might offer additional client-side functionality, but there's no one standard.Thanks,EilonBlog: I mean. When I am using html control in my aspx page like:  <input type=text ..>  and...

Hello, I've come across the problem when I wanted to use client side validation (no matter of which type) depending on the input from a different control. The scenario is: I have two textboxes A and B. A does not need to be validated (no validator associated with A). The textbox B has to be validated if and only if the A has any value. I know this is trivial with custom validator in the server side mode... But unfortunately I want it to run the validation on the client side. And I also know that I can write a javascript function for the ClientValidationFunction and hardcode client id ...

validation controls
Hi all,I have a web form with a few controls and reqdfield, compare & regex validation controls. On all validation controls i have enabled the client script property. Yet when I submit the form it does a postback to do the validation. Any ideas? I am running vs2005 beta 2.TIA! do these validators perform the validation of the other controlos? whar browser are you using?-- Regards,Luis Abreuemail: labreu_at_gmail.comEN blog: Well they are regular requiredfield, regex & compare validators. Browser is latest version of Firefox. I had to use...

Validation control not doing server side validation?
I think the subject covers what I'm asking.  I want to run some checks on the data that was entered after the page was submitted, but I don't know how to handle it if there's a problem the user has to go back and fix.  So I thought I'd try to work around the validation control to see how .NET handles it.  I have a text field that is required.  When the submit button is clicked, I assume some client side validation is run.  I get the validation message I want and the form won't submit.   But then I made a change in the on click event of the submit butto...

Web resources about - Scroll to bottom of page after server control validation -

Cross-validation (statistics) - Wikipedia, the free encyclopedia
is a model validation technique for assessing how the results of a statistical analysis will generalize to an independent data set. It is mainly ...

Serena Williams eyes history, Caroline Wozniacki craves validation in women's US Open final
As Serena Williams eyes another slice of tennis history, Caroline Wozniacki is craving validation with a watershed US Open final triumph on Sunday ...

Travers Duncan asks High Court to strike down ICAC validation laws
ICAC could be sent back to the High Court as a challenge to new laws validating corruption findings looms.

Adam Scott proclaims Texas win as validation of No.1 ranking
... No.1 golfer, beating American Jason Dufner in the third hole of a play-off at the Colonial event. "It's a good feeling and maybe some validation ...

Hollande to sign gay marriage bill after Constitutional Council's validation
Hollande to sign gay marriage bill after Constitutional Council's validation People's Daily Online ... 26, 27, 28, 29, 30, 31. Jan, Feb, Mar, ...

Marketers, Get Ready for the 'Validation Era'
The public brands included has been engaging in a "friends" arms race. But there are signs that we know we overdid it.

Validation and Uncertainty
What an extraordinary conversation I had recently on Twitter. It started with Neil Killick’s statement that we should not consider our stories ...

Nvidia Icera 410 LTE Modem Passes AT&T Network Validation
... Today's news is a small step and logical precursor toward both goals, Nvidia's Icera 410 LTE and HSPA+ baseband has passed AT&T's network validation ...

Ting’s Q1 Subscriber Growth Suffers from Sprint’s New Unlocking Validation Process
Back in February, Sprint updated the process it uses to validate unlocked devices that customers want to utilize on other carriers or one of ...

[Android M Feature Spotlight] Stricter APK Validation Now Actually Checks If All Of An APK's Files Are ...
While you might file this one under "really? We weren't doing this already?" if you're a security expert, Google has added stricter validation ...

Resources last updated: 12/14/2015 11:00:03 PM