user1718095
user1718095

Reputation: 1

Go to top of page when making Panel Visible

I have a simple 2 panel form that I am setting up. I created this button on my aspx page:

<asp:Button runat='server' ID='NextButton' Text='Half Way There Proceed' OnClick='StepTwoPanel_Click' />

And then this is in my aspx.cs file:

protected void StepTwoPanel_Click(object sender, EventArgs e)
{

 StepOnePanel.Visible = false;

 StepTwoPanel.Visible = true;
}

When I use this, it works perfectly to go from panel one to panel two. Only one little problem. Instead of taking the user to the top of the second panel, they are near the bottom of the panel, exactly where they were on the page when they clicked the button in the first panel.

My question is, when the button click makes the second panel visible, how can it also direct the page back to the top?

Upvotes: 0

Views: 1266

Answers (2)

unnknown
unnknown

Reputation: 1775

Could you perhaps scroll to your desired location using Javascript?

Your Button:

<asp:Button runat='server' OnClientClick="ScrollTheThing" ID='NextButton' Text='Half Way There Proceed' OnClick='StepTwoPanel_Click' />

Its Javascript Handler:

function ScrollTheThing()  {

    // Code to scroll where you need

}

For exactly how to perform the scroll, these might give some ideas: http://www.mediacollege.com/internet/javascript/page/scroll.html

http://www.west-wind.com/weblog/posts/2006/Feb/24/Retrieving-Browser-Scroll-Position-in-JavaScript

Upvotes: 0

Amit Gaikwad
Amit Gaikwad

Reputation: 86

make MaintainScrollPositionOnPostBack = false; When the MaintainScrollPositionOnPostback property is set to true, the user is instead returned to the last position on the page. http://www.c-sharpcorner.com/UploadFile/yogesh12/PostBack12292006050702AM/PostBack.aspx

Upvotes: 1

Related Questions