Solved

How do I prevent an ASP.NET page from jumping upon postback?

Posted on 2006-06-23
14
1,411 Views
Last Modified: 2008-01-09
I have a radio button list that, when selected, immedietly does a post back and reveals another radio button list. That list changes depending on what the user selected on the first radio button list.

This works fine except for one aggravating problem. Every time it does postback the user is placed back at the top of the page. How do I make this page so the user's page doesn't move?
0
Comment
Question by:M3hcSS
  • 4
  • 4
  • 2
  • +4
14 Comments
 
LVL 2

Author Comment

by:M3hcSS
ID: 16971693
I mean to say, I don't want the user to scroll down the page every time they do a selection.
0
 
LVL 5

Assisted Solution

by:Collindsouza
Collindsouza earned 60 total points
ID: 16971796
You need to show hide the Second Set of radio button using Javascript.. Assuming that your using DIV's you need to write client side Javascript that on click on Radio Button A.. will show/hide radio Button B
0
 
LVL 1

Expert Comment

by:EnolaKotrotsos
ID: 16972206
put the buttons in an iFrame container or use AJAX (.NET has the Atlas implementation- search google)
Marco
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 16972230
Basically you cannot allow asp to do this for you.  Instead you need to use client side code (javascript as mentioned above) to manually do this.  You don't need AJAX for simply hiding and showing additional radio button groups.  But if the content needs to look up information in the database then AJAX could be used.
0
 
LVL 2

Author Comment

by:M3hcSS
ID: 16972438
It's not possible to use something inside Visual Studio in order to anchor the page?
0
 
LVL 35

Accepted Solution

by:
mrichmon earned 65 total points
ID: 16972523
No.

You can use javascript to scroll the page back down to the radio location (again you are using javascript), but that is not a very nice user interface.  Basically you should not need to post the page just because the user changes the radio selection.  Therefore you should have javascript handle this.
0
 
LVL 2

Author Comment

by:M3hcSS
ID: 16972846
Ok, let me try to figure out this javascript thingy (I haven't used javascripting in conjunction with a .NET page), and then I shall distribute the points accordingly.

Thanks for your time. I appreciate it.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 35

Expert Comment

by:mrichmon
ID: 16973232
Let us know if you have specific questions when trying to figure it out.

One thing you may run into is that you may have to access the radio buttions as html elements and not hte .NET controls.
0
 
LVL 5

Expert Comment

by:Collindsouza
ID: 16973245
True..

You need to use Html Radio button Controls.. with runat="server" attribute

Cheers,
Collin
0
 
LVL 35

Expert Comment

by:mrichmon
ID: 16973412
Yes that is what I was referring to....

Also on the backend you will access as:
HtmlInputRadioButton

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconASPSyntaxForHTMLControls.asp
0
 
LVL 4

Expert Comment

by:gregg1ep00
ID: 16973749
If you're using ASP.NET 2.0, have you tried setting the Page.MaintainScrollPositionOnPostBack property to true?

If you're using ASP.NET 1.1, you can set the SmartNavigation attribute in the <%@ Page %> directive to true.
0
 
LVL 3

Expert Comment

by:rinksno1
ID: 16974621
gregg1ep00 solution will work!!......
0
 
LVL 15

Expert Comment

by:justinbillig
ID: 16984585
smartnavigation is IE only
0
 
LVL 2

Author Comment

by:M3hcSS
ID: 16985866
<<<If you're using ASP.NET 1.1, you can set the SmartNavigation attribute in the <%@ Page %> directive to true.

I set this attribute to "true" yet the page still jumps to the top. I'm using IE 6.0 with asp.net 1.1. It would seem that it should work.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now