aspx page going to top after refresh

  • Thread starter Thread starter apm
  • Start date Start date
A

apm

All or rather anyone:

I am developing web forms (.aspx pages) that accept inputs from the user at
the top of the page. Near the bottom is a submit button. Also near the
bottom is a text box where the result of a calculation is displayed.

The problem is that when the submit button is clicked at the bottom of the
page the top of the page is displayed after the server returns control to
the client. The user than has to scroll to the bottom of the page to see the
result.

Is there a way to return to the section of the page where the button is
clicked? How can the code remember the scroll state?

David
 
apm said:
All or rather anyone:

I am developing web forms (.aspx pages) that accept inputs from the user at
the top of the page. Near the bottom is a submit button. Also near the
bottom is a text box where the result of a calculation is displayed.

The problem is that when the submit button is clicked at the bottom of the
page the top of the page is displayed after the server returns control to
the client. The user than has to scroll to the bottom of the page to see the
result.

Is there a way to return to the section of the page where the button is
clicked? How can the code remember the scroll state?

David

You'd have to do the scrolling through javascript. I don't know the
syntax for jumping down a page, but I'm sure you can find it through
your favorite search engine.
 
check out the SmartNavigation property for a aspx page, note this only works
in IE.

HTH

Ollie Riches
 
Hi,

Indeed, and it's very easy to do, just a little javascript:

All you have to do is put a <a name="Come2me"> tag where you want it to be
visible. then use the code below to go there:

Now, the example below is dynamic, I have a big list and I need to
positioning it dynamically, so I put the tag where I need it to be in the
code behind.

<script>
var gotomark = "";
function GotoMark()
{
if ( gotomark !='')
location = "#"+ gotomark;
}
</script>

<body MS_POSITIONING="GridLayout" bottommargin=0 topmargin=0
onload="GotoMark();">


Let me know if you need further code snippets


cheers,
 
Thank you all. What really bothers me is that returning to the original view
location (or scroll possition) is not the default. Resetting scroll
possition may be the only way to get the page to return to the exact spot.
Anyone know how to do that in javascript? IE and Netscape? Some of the app
will never run with Navigater but perhaps some can.

In a day or two I'll answer this question myself but I am not beyond using
someone elses script if its faster.

Thanks again.

David
 
Anchor the spot you want to return to and then in code you can return to that
point using Server.Transfer("somepage.aspx#TargetAnchorGoesHere");
 
Hi,

The snip I posted do work with anything that support javascript, as I said
it's very easy just create a anchor and change the location to #anchorname

cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top