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

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?
LVL 2
M3hcSSAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
mrichmonConnect With a Mentor Commented:
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
 
M3hcSSAuthor Commented:
I mean to say, I don't want the user to scroll down the page every time they do a selection.
0
 
CollindsouzaConnect With a Mentor Commented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
EnolaKotrotsosCommented:
put the buttons in an iFrame container or use AJAX (.NET has the Atlas implementation- search google)
Marco
0
 
mrichmonCommented:
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
 
M3hcSSAuthor Commented:
It's not possible to use something inside Visual Studio in order to anchor the page?
0
 
M3hcSSAuthor Commented:
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
 
mrichmonCommented:
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
 
CollindsouzaCommented:
True..

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

Cheers,
Collin
0
 
mrichmonCommented:
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
 
gregg1ep00Commented:
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
 
rinksno1Commented:
gregg1ep00 solution will work!!......
0
 
justinbilligCommented:
smartnavigation is IE only
0
 
M3hcSSAuthor Commented:
<<<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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.