WebForm scroll position after PostBack

S

Steve Covert

In the case of a long Webform, when a PostBack event occurrs, is there a
technique to position the Form at where it was when the event fired?

Similar to using an anchor tag in html to go to a specific location in a
page.

Thanks!
 
A

alex bowers

You can render html to the browser that uses the Anchor
tag to go to a specific location.
the following code writes out an <A> tag to the browser
(you'll need to insert it in the appropriate place), and
runs a script that positions the form at that spot.

[C#]
string Arg = Request.Form["__EVENTARGUMENT"];
n.Text += "<A name='#" + Arg + "'></A>";
string script = "<SCRIPT
language='javascript'>location.href='#" + Arg
+ "';</SCRIPT>";
Page.RegisterStartupScript("posForm",script);

You don't need to use Request.Form["__EVENTARGUMENT"],
any string will do here but it can help if you're trying
to determine which event that caused the postback

alex
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top