473,396 Members | 1,833 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,396 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 1586
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.