Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load()
Browser Back Button And Page_Load() Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Go Back  Xtreme Visual Basic Talk > > > Browser Back Button And Page_Load()


Reply
 
Thread Tools Display Modes
  #1  
Old 04-25-2011, 10:02 AM
bradptti bradptti is offline
Regular
 
Join Date: Nov 2002
Posts: 72
Default Browser Back Button And Page_Load()


Hello Everyone,

I am working on a web app in which a user will read some pages and then take a quiz. On the quiz, they will go through and answer 10 questions. These questions are displayed in a table on a single ASPX page using a Redirect to the current page and getting question from database to display. There are "Next"/"Prev" buttons on this page so that the user can go back to questions to check/change their answer before they hit the submit button. Everything works just fine here with the buttons. If they click "Prev" button it looks in the database what value they chose for that question and marks the correct radio button accordingly. My issue is in the following scenario. Say they answered the first 5 questions and clicked the browser back button (instead of the "Prev" button I placed on the form) to look at their answer for number 3 (so they click the browser back button twice). Now, if they happen to click on the "Next" button I placed on the form, instead of going to question number 4, it puts them on question number 6. I believe this is because I have set a Session variable for the current question number when the "Next"/"Prev" buttons I created are clicked. Then these buttons of mine call Response.Redirect("quiz.aspx"); which is the current page, basically it is re-loading the page displaying the question and/or answer from the database. However, when the browser back button is clicked, no Session variable is getting set to indicate which question to load, plus the Page_Load() event does not fire with the browser back button.

Does anyone know what I can do to basically call my code-behind routine like my "Next"/"Prev" buttons and the do a page load? What I would really like to do is check a Session variable on page load and if it was not set from my "Next"/"Prev" buttons, then it assumes the browser back button was clicked. Or if there was a way in javascript to call my "Prev" button function in code-behind. Any ideas?

Thanks In Advance,

Brad
Reply With Quote
  #2  
Old 06-01-2011, 01:39 PM
alexsts alexsts is offline
Freshman
 
Join Date: Apr 2010
Posts: 32
Default

Reset session variable depend on ID of the page loaded.
Simple as that.
If you load page 5 then session variable will be 5 if user click on prev or back button page ID from URL will be 4 and session variable will get reset to 4.
You can resolve this by using select case (classic ASP)/ switch(C#) on code level.
If you need to see his progress then introduce different session variable for that purpose alone.
But more reasonable for test would be disable or completely remove browser navigation while opening test window. Assuming that you do open test in separate window like pop-up...

Last edited by alexsts; 06-01-2011 at 01:45 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load() Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load() Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
 
Browser Back Button And Page_Load()
Browser Back Button And Page_Load()
 
-->