Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2006-06-23
14
1,418 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

791 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