I have a very big form with lots of questions for the user to answer. Almost all of the controls are AutoPostBack as some other controls are enabled/disabled depending on thier answers. But if suppose I click on a radiobutton with AutoPostBack On, the page
reloads as it should, but takes me to the top and then I have scroll back down to answer the next question. How to avoid that? It's a long form and I want theleast inconvenience to the user....
I just know that AJAX can help me control this, but I don't know where to start... Can anyone suggest something?
The most easiest solution is use UpdatePanel put your all controls that cause post back in that , it will no longer post backs
To use update panel first drag Scriptmanager then dragupdate panel
Update panel needs two things , one is the control/object which we dont want to cause post back second is trigger of the control that causes it post back ,update progress will show the time consumed animation or some text while the control is processing
like
Thanks umairaslam, salman behera and chetan sarode. All those websites were really helpful. Thanks a lot. I didn't know there were so many ways of doing this...
MoneyRan
Member
455 Points
228 Posts
AutoPostBack Controls refresh the page and go to top
Nov 04, 2011 09:05 PM|LINK
Hello all,
I have a very big form with lots of questions for the user to answer. Almost all of the controls are AutoPostBack as some other controls are enabled/disabled depending on thier answers. But if suppose I click on a radiobutton with AutoPostBack On, the page reloads as it should, but takes me to the top and then I have scroll back down to answer the next question. How to avoid that? It's a long form and I want theleast inconvenience to the user....
I just know that AJAX can help me control this, but I don't know where to start... Can anyone suggest something?
umairaslam22
Contributor
3990 Points
845 Posts
Re: AutoPostBack Controls refresh the page and go to top
Nov 05, 2011 04:44 AM|LINK
The most easiest solution is use UpdatePanel put your all controls that cause post back in that , it will no longer post backs
To use update panel first drag Scriptmanager then dragupdate panel
Update panel needs two things , one is the control/object which we dont want to cause post back second is trigger of the control that causes it post back ,update progress will show the time consumed animation or some text while the control is processing like
here is the sample
<asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:RadioButton ID="btn1" runat="server" Text="1" GroupName="MyGroup1" AutoPostBack="true" Checked="true" /> <asp:RadioButton ID="btn2" runat="server" Text="2" GroupName="MyGroup1" AutoPostBack="true" /> <asp:UpdateProgress ID="MyUpdateProgress" runat="server" AssociatedUpdatePanelID="MyUpdatePanel"> <ProgressTemplate> <h1>Loading</h1> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel ID="MyUpdatePanel" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="lblTime" runat="server" /> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="btn1" EventName="CheckedChanged" /> <asp:AsyncPostBackTrigger ControlID="btn2" EventName="CheckedChanged" /> </Triggers> </asp:UpdatePanel>MCP
Blog
Please remember to Mark as answer if any post help you , it help others to find right solution in less time
salman beher...
All-Star
30579 Points
5852 Posts
Re: AutoPostBack Controls refresh the page and go to top
Nov 06, 2011 10:57 AM|LINK
Hi,
solution here....
http://weblogs.asp.net/hosamkamel/archive/2007/09/07/maintain-scroll-position-after-postbacks-in-asp-net-2-0.aspx
http://forums.asp.net/t/1613485.aspx/1
Thanks...
Sincerely,
Salman
chetan.sarod...
All-Star
65729 Points
11138 Posts
Re: AutoPostBack Controls refresh the page and go to top
Nov 07, 2011 02:12 AM|LINK
Hi, Pleas erefer this
http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/
http://disturbedbuddha.wordpress.com/2007/12/03/maintain-scroll-position-after-asynchronous-postback/
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
MoneyRan
Member
455 Points
228 Posts
Re: AutoPostBack Controls refresh the page and go to top
Nov 10, 2011 02:02 PM|LINK
Thanks umairaslam, salman behera and chetan sarode. All those websites were really helpful. Thanks a lot. I didn't know there were so many ways of doing this...