Solved

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

Posted on 2006-06-23
14
1,442 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
[X]
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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

635 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