473,320 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Returning page to current position after sending request to server

I am creating a form, and when a user clicks on the ASP.NET calendar control, or on another checkbox that sends a request to the server, the page reloads fine, except that it is at the top of the page, instead of where it was originally. Is there an easy way to move the page back to the current position? or does it have to be individually coded. If individually coded, how might that look? thank

Devin
Nov 18 '05 #1
1 1581
Hi Devin,

you can use this function call the RetainScrollLocation in the pageload and
everything will work fine.

HTH
Regards
Ashish M Bhonkiya
private void RetainScrollLocation()
{
StringBuilder myScriptCodeSave = new StringBuilder();
RegisterHiddenField("_SCROLLLOCATION_", "0");

myScriptCodeSave.Append("<script language='javascript'>");
myScriptCodeSave.Append("function saveScrollLocation() {");
myScriptCodeSave.Append("
document.forms[0]._SCROLLLOCATION_.value = document.body.scrollTop;");
myScriptCodeSave.Append("}");

myScriptCodeSave.Append("document.body.onscroll=sa veScrollLocation;");
myScriptCodeSave.Append("</script>");

RegisterStartupScript("saveScrollLocation",
myScriptCodeSave.ToString());

if (Page.IsPostBack)
{

StringBuilder myScriptCodeSet = new StringBuilder();

myScriptCodeSet.Append("<script language='javascript'>");
myScriptCodeSet.Append("function setScrollLocation() {");
myScriptCodeSet.Append(" document.body.scrollTop = " +
Request["_SCROLLLOCATION_"] + ";");
myScriptCodeSet.Append("}");

myScriptCodeSet.Append("document.body.onload=setSc rollLocation;");
myScriptCodeSet.Append("</script>");

this.RegisterStartupScript("setScrollLocation",
myScriptCodeSet.ToString());

}

}

"Devin" <an*******@discussions.microsoft.com> wrote in message
news:17**********************************@microsof t.com...
I am creating a form, and when a user clicks on the ASP.NET calendar control, or on another checkbox that sends a request to the server, the page
reloads fine, except that it is at the top of the page, instead of where it
was originally. Is there an easy way to move the page back to the current
position? or does it have to be individually coded. If individually coded,
how might that look? thanks
Devin

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Marcelo | last post by:
Hi guys, I'm using the following code to send values from one page to another, but seems to me, that the event Page_Load in the receiving page never fires. Why? This is the code: Thanks ...
2
by: Stephen Miller | last post by:
I have an ASPX report and I want to capture the rendered HTML and write to a file on the webserver. Several posts suggest using WebRequest to make a second call to the page, and screen-scrape the...
1
by: Devin | last post by:
I am creating a form, and when a user clicks on the ASP.NET calendar control, or on another checkbox that sends a request to the server, the page reloads fine, except that it is at the top of the...
0
by: Goober at christianDOTnet | last post by:
I'm wanting to fix the following on a web page without really re-inventing anything. What I have is a vb web page with a radiobuttonlist where I can pick Current or History year. Underneath...
0
by: GFro | last post by:
I have a calendar page that returns a date to a textbox on the parent page. It is returning the wrong format on the deployment server. On the development server the calendar returns to textbox in...
13
by: tshad | last post by:
I have some nested DataGrids in my Datalist. There could be 20 datalist items. If I scroll down to the 18th item and expand it to show the DataGrid, the page always goes back to the beginning...
1
by: Eric Sheu | last post by:
Greetings, I have been searching the web like mad for a solution to my SMTP problem. I am using Windows Server 2003 and ASP.NET 2.0 w/ C# to send out e-mails from a web site I have created to...
4
by: Landes | last post by:
Hiya, I have the following code in a C# aspx page, but I keep getting the error that 'ExceptionCategoryId_' not found. Looks like the QueryString is not returning anything. <asp:DataGrid...
8
by: cyberdawg999 | last post by:
hello all every time my page loads it inserts a empty record into my database and when a new record gets inserted a blank record gets inserted and on the next page load and submit the previous...
0
by: cyberdawg999 | last post by:
Greetings all in ASP land I have overcome one obstacle that took me 2 weeks to overcome and I did it!!!!! I am so elated!! thank you to all who invested their time and energy towards helping me...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.