Return to previous page

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • staeri@gmail.com

    Return to previous page

    I use javascript:hist ory.go(-1) to return to the previous page.

    I've now found out that when returning to the previous page all
    selections that the user made in dropdownlists are lost. How can these
    be kept when returning?

    I'm very grateful for fast response.

    // S
  • Stan

    #2
    Re: Return to previous page

    On 15 May, 07:10, sta...@gmail.co m wrote:
    I use javascript:hist ory.go(-1) to return to the previous page.
    >
    I've now found out that when returning to the previous page all
    selections that the user made in dropdownlists are lost. How can these
    be kept when returning?
    >
    I'm very grateful for fast response.
    >
    // S
    The previous data is lost because the browser has no way of retaining
    it.

    You have to use postback events to do the redirection and store the
    data in session state.

    Comment

    • Peter Bucher [MVP]

      #3
      Re: Return to previous page

      Hello Staeri

      How do you return to the last Page?
      If with "history.go(1); , all should work as expected,
      because you are only navigating on the browser history.

      --
      Gruss, Peter Bucher
      Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
      http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
      http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

      Comment

      • Mark Rae [MVP]

        #4
        Re: Return to previous page

        "Peter Bucher [MVP]" <peter.bucher@a spnetzone.dewro te in message
        news:079DFD71-D211-4B78-BC87-3B4061718F27@mi crosoft.com...
        How do you return to the last Page?
        If with "history.go(1); , all should work as expected,
        because you are only navigating on the browser history.
        Clearly, that won't do what the OP wants, because that will simply open the
        previous page as it was previously opened... Changes to DropDownLists,
        TextBoxes etc will not be "remembered " because ASP.NET has no way of
        "rememberin g" them unless as a result of a postback...


        --
        Mark Rae
        ASP.NET MVP


        Comment

        • Mark Rae [MVP]

          #5
          Re: Return to previous page

          <staeri@gmail.c omwrote in message
          news:3e5837d1-08a6-4ceb-8b48-1bb0afc2af9f@56 g2000hsm.google groups.com...
          >I use javascript:hist ory.go(-1) to return to the previous page.
          I've now found out that when returning to the previous page all
          selections that the user made in dropdownlists are lost.
          Obviously. When you hit the Back button (either directly or in the above
          code), the browser opens the previous page in exactly the same way as it was
          previously opened - it has no way of "rememberin g" any client-side
          modifications made to that page unless they were posted back...


          --
          Mark Rae
          ASP.NET MVP


          Comment

          • staeri@gmail.com

            #6
            Re: Return to previous page

            On 15 Maj, 10:15, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
            <sta...@gmail.c omwrote in message
            >
            news:3e5837d1-08a6-4ceb-8b48-1bb0afc2af9f@56 g2000hsm.google groups.com...
            >
            I use javascript:hist ory.go(-1) to return to the previous page.
            I've now found out that when returning to the previous page all
            selections that the user made in dropdownlists are lost.
            >
            Obviously. When you hit the Back button (either directly or in the above
            code), the browser opens the previous page in exactly the same way as it was
            previously opened - it has no way of "rememberin g" any client-side
            modifications made to that page unless they were posted back...
            >
            --
            Mark Rae
            ASP.NET MVPhttp://www.markrae.net
            Thank you for the answers!

            I've stored the dropdownlist selections in sessions but is there a way
            to set the dropdownlist selections to the session values when the page
            is showed again when clicking the return button with
            javascript:hist ory.go(-1)? If it can be made without changing the url
            I'm very happy because otherwise there are a lot changes I have to
            make because of iframe etc.

            // S

            Comment

            • Eliyahu Goldin

              #7
              Re: Return to previous page

              Sure. You just need to restore selection from the session in the Page_Load
              event.

              --
              Eliyahu Goldin,
              Software Developer
              Microsoft MVP [ASP.NET]




              <staeri@gmail.c omwrote in message
              news:91043678-6334-42af-bcc4-63dc8c4eeac6@34 g2000hsh.google groups.com...
              On 15 Maj, 10:15, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
              ><sta...@gmail. comwrote in message
              >>
              >news:3e5837d 1-08a6-4ceb-8b48-1bb0afc2af9f@56 g2000hsm.google groups.com...
              >>
              >I use javascript:hist ory.go(-1) to return to the previous page.
              I've now found out that when returning to the previous page all
              selections that the user made in dropdownlists are lost.
              >>
              >Obviously. When you hit the Back button (either directly or in the above
              >code), the browser opens the previous page in exactly the same way as it
              >was
              >previously opened - it has no way of "rememberin g" any client-side
              >modification s made to that page unless they were posted back...
              >>
              >--
              >Mark Rae
              >ASP.NET MVPhttp://www.markrae.net
              >
              Thank you for the answers!
              >
              I've stored the dropdownlist selections in sessions but is there a way
              to set the dropdownlist selections to the session values when the page
              is showed again when clicking the return button with
              javascript:hist ory.go(-1)? If it can be made without changing the url
              I'm very happy because otherwise there are a lot changes I have to
              make because of iframe etc.
              >
              // S

              Comment

              • staeri@gmail.com

                #8
                Re: Return to previous page

                On 15 Maj, 11:18, "Eliyahu Goldin"
                <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
                Sure. You just need to restore selection from the session in the Page_Load
                event.
                >
                --
                Eliyahu Goldin,
                Software Developer
                Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
                >
                <sta...@gmail.c omwrote in message
                >
                news:91043678-6334-42af-bcc4-63dc8c4eeac6@34 g2000hsh.google groups.com...
                >
                >
                >
                On 15 Maj, 10:15, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                <sta...@gmail.c omwrote in message
                >
                >news:3e5837d 1-08a6-4ceb-8b48-1bb0afc2af9f@56 g2000hsm.google groups.com...
                >
                I use javascript:hist ory.go(-1) to return to the previous page.
                I've now found out that when returning to the previous page all
                selections that the user made in dropdownlists are lost.
                >
                Obviously. When you hit the Back button (either directly or in the above
                code), the browser opens the previous page in exactly the same way as it
                was
                previously opened - it has no way of "rememberin g" any client-side
                modifications made to that page unless they were posted back...
                >
                --
                Mark Rae
                ASP.NET MVPhttp://www.markrae.net
                >
                Thank you for the answers!
                >
                I've stored the dropdownlist selections in sessions but is there a way
                to set the dropdownlist selections to the session values when the page
                is showed again when clicking the return button with
                javascript:hist ory.go(-1)? If it can be made without changing the url
                I'm very happy because otherwise there are a lot changes I have to
                make because of iframe etc.
                >
                // S- Dölj citerad text -
                >
                - Visa citerad text -
                It looks like Page_Load isn't fired when returning to the page by
                using javascript:hist ory.go(-1). Is that correct?

                // S

                Comment

                • Eliyahu Goldin

                  #9
                  Re: Return to previous page

                  This means the browser gets it from the cache. location.reload (true) will
                  always go to the server. You need to think how to combine both history and
                  location calls.

                  --
                  Eliyahu Goldin,
                  Software Developer
                  Microsoft MVP [ASP.NET]




                  <staeri@gmail.c omwrote in message
                  news:1237d480-f8ec-49ee-ada6-44619948643f@2g 2000hsn.googleg roups.com...
                  On 15 Maj, 11:18, "Eliyahu Goldin"
                  <REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
                  Sure. You just need to restore selection from the session in the Page_Load
                  event.
                  >
                  --
                  Eliyahu Goldin,
                  Software Developer
                  Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
                  >
                  <sta...@gmail.c omwrote in message
                  >
                  news:91043678-6334-42af-bcc4-63dc8c4eeac6@34 g2000hsh.google groups.com...
                  >
                  >
                  >
                  On 15 Maj, 10:15, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                  <sta...@gmail.c omwrote in message
                  >
                  >news:3e5837d 1-08a6-4ceb-8b48-1bb0afc2af9f@56 g2000hsm.google groups.com...
                  >
                  I use javascript:hist ory.go(-1) to return to the previous page.
                  I've now found out that when returning to the previous page all
                  selections that the user made in dropdownlists are lost.
                  >
                  Obviously. When you hit the Back button (either directly or in the
                  above
                  code), the browser opens the previous page in exactly the same way as
                  it
                  was
                  previously opened - it has no way of "rememberin g" any client-side
                  modifications made to that page unless they were posted back...
                  >
                  --
                  Mark Rae
                  ASP.NET MVPhttp://www.markrae.net
                  >
                  Thank you for the answers!
                  >
                  I've stored the dropdownlist selections in sessions but is there a way
                  to set the dropdownlist selections to the session values when the page
                  is showed again when clicking the return button with
                  javascript:hist ory.go(-1)? If it can be made without changing the url
                  I'm very happy because otherwise there are a lot changes I have to
                  make because of iframe etc.
                  >
                  // S- Dölj citerad text -
                  >
                  - Visa citerad text -
                  It looks like Page_Load isn't fired when returning to the page by
                  using javascript:hist ory.go(-1). Is that correct?

                  // S


                  Comment

                  • Mark Rae [MVP]

                    #10
                    Re: Return to previous page

                    <staeri@gmail.c omwrote in message
                    news:91043678-6334-42af-bcc4-63dc8c4eeac6@34 g2000hsh.google groups.com...
                    I've stored the dropdownlist selections in sessions
                    Ah - you didn't mention that in your original post...
                    but is there a way to set the dropdownlist selections to the session
                    values
                    when the page is showed again when clicking the return button with
                    javascript:hist ory.go(-1)? If it can be made without changing the url
                    I'm very happy because otherwise there are a lot changes I have to
                    make because of iframe etc.
                    iframe? You didn't mention that either in your original post...

                    Anyway, as I see you've already discovered, session won't help you here
                    because the page is being fetched from cache. Therefore, you'll need to find
                    some way of preventing this which, depending on how you've set your app up,
                    will be either fairly trivial or next to impossible:




                    --
                    Mark Rae
                    ASP.NET MVP


                    Comment

                    • Patrice

                      #11
                      Re: Return to previous page

                      What is the purpose of using the back button ?

                      The intended use is to display the previous page as it was previously seen
                      by the user. You could also prevent this page from being cached browser side
                      so that it is fetched again from the server (and possibly then updated).

                      Or perhaps should you implemnt your own link. What is the meaning of using
                      the back button in your case ?

                      --
                      Patrice

                      <staeri@gmail.c oma écrit dans le message de groupe de discussion :
                      3e5837d1-08a6-4ceb-8b48-1bb0afc2af9f...le groups.com...
                      I use javascript:hist ory.go(-1) to return to the previous page.
                      >
                      I've now found out that when returning to the previous page all
                      selections that the user made in dropdownlists are lost. How can these
                      be kept when returning?
                      >
                      I'm very grateful for fast response.
                      >
                      // S

                      Comment

                      • staeri@gmail.com

                        #12
                        Re: Return to previous page

                        On 15 Maj, 13:20, "Patrice" <http://www.chez.com/scribe/wrote:
                        What is the purpose of using the back button ?
                        >
                        The intended use is to display the previous page as it was previously seen
                        by the user. You could also prevent this page from being cached browser side
                        so that it is fetched again from the server (and possibly then updated).
                        >
                        Or perhaps should you implemnt your own link. What is the meaning of using
                        the back button in your case ?
                        >
                        --
                        Patrice
                        >
                        <sta...@gmail.c oma écrit dans le message de groupe de discussion :
                        3e5837d1-08a6-4ceb-8b48-1bb0afc2a...@56 g2000hsm.google groups.com...
                        >
                        >
                        >
                        I use javascript:hist ory.go(-1) to return to the previous page.
                        >
                        I've now found out that when returning to the previous page all
                        selections that the user made in dropdownlists are lost. How can these
                        be kept when returning?
                        >
                        I'm very grateful for fast response.
                        >
                        // S- Dölj citerad text -
                        >
                        - Visa citerad text -
                        The purpose of the back button is to display the previous page as it
                        was previously seen by the user. How I go back to the previous page
                        doesn't matter as long as the url isn't changed.

                        // S

                        Comment

                        • Stan

                          #13
                          Re: Return to previous page

                          On 15 May, 17:22, sta...@gmail.co m wrote:
                          On 15 Maj, 13:20, "Patrice" <http://www.chez.com/scribe/wrote:
                          >
                          >
                          >
                          >
                          >
                          What is the purpose of using the back button ?
                          >
                          The intended use is to display the previous page as it was previously seen
                          by the user. You could also prevent this page from being cached browser side
                          so that it is fetched again from the server (and possibly then updated).
                          >
                          Or perhaps should you implemnt your own link. What is the meaning of using
                          the back button in your case ?
                          >
                          --
                          Patrice
                          >
                          <sta...@gmail.c oma écrit dans le message de groupe de discussion :
                          3e5837d1-08a6-4ceb-8b48-1bb0afc2a...@56 g2000hsm.google groups.com...
                          >
                          I use javascript:hist ory.go(-1) to return to the previous page.
                          >
                          I've now found out that when returning to the previous page all
                          selections that the user made in dropdownlists are lost. How can these
                          be kept when returning?
                          >
                          I'm very grateful for fast response.
                          >
                          // S- Dölj citerad text -
                          >
                          - Visa citerad text -
                          >
                          The purpose of the back button is to display the previous page as it
                          was previously seen by the user. How I go back to the previous page
                          doesn't matter as long as the url isn't changed.
                          >
                          // S- Hide quoted text -
                          >
                          - Show quoted text -
                          There is another approach to this that might be helpful.

                          Your problem seems to be that you are going away from the first page
                          when the user initiates a request for the second page. Hence the
                          browser reloads the first from scratch when you return to it (either
                          from the local cache or from the server but will make no difference).

                          Session state can be used to overcome this but an easier solution is
                          to use a single page with a MultiView control with two Views (one view
                          for each formerly separate page). That way ViewSate will retain the
                          content of any web server controls in both views because switching
                          between then will only occur on postback (but use a postback command
                          button to do the going back not one that does it via the browser using
                          JavaScript).

                          HTH


                          Comment

                          • staeri@gmail.com

                            #14
                            Re: Return to previous page

                            On 15 Maj, 19:26, Stan <googles...@phi lhall.netwrote:
                            On 15 May, 17:22, sta...@gmail.co m wrote:
                            >
                            >
                            >
                            >
                            >
                            On 15 Maj, 13:20, "Patrice" <http://www.chez.com/scribe/wrote:
                            >
                            What is the purpose of using the back button ?
                            >
                            The intended use is to display the previous page as it was previously seen
                            by the user. You could also prevent this page from being cached browser side
                            so that it is fetched again from the server (and possibly then updated).
                            >
                            Or perhaps should you implemnt your own link. What is the meaning of using
                            the back button in your case ?
                            >
                            --
                            Patrice
                            >
                            <sta...@gmail.c oma écrit dans le message de groupe de discussion :
                            3e5837d1-08a6-4ceb-8b48-1bb0afc2a...@56 g2000hsm.google groups.com...
                            >
                            I use javascript:hist ory.go(-1) to return to the previous page.
                            >
                            I've now found out that when returning to the previous page all
                            selections that the user made in dropdownlists are lost. How can these
                            be kept when returning?
                            >
                            I'm very grateful for fast response.
                            >
                            // S- Dölj citerad text -
                            >
                            - Visa citerad text -
                            >
                            The purpose of the back button is to display the previous page as it
                            was previously seen by the user. How I go back to the previous page
                            doesn't matter as long as the url isn't changed.
                            >
                            // S- Hide quoted text -
                            >
                            - Show quoted text -
                            >
                            There is another approach to this that might be helpful.
                            >
                            Your problem seems to be that you are going away from the first page
                            when the user initiates a request for the second page. Hence the
                            browser reloads the first from scratch when you return to it (either
                            from the local cache or from the server but will make no difference).
                            >
                            Session state can be used to overcome this but an easier solution is
                            to use a single page with a MultiView control with two Views (one view
                            for each formerly separate page). That way ViewSate will retain the
                            content of any web server controls in both views because switching
                            between then will only occur on postback (but use a postback command
                            button to do the going back not one that does it via the browser using
                            JavaScript).
                            >
                            HTH- Dölj citerad text -
                            >
                            - Visa citerad text -
                            Thank you for the suggestion, Stan! Will there be any performance
                            degradation when using a MultiView? Will both views be loaded
                            initially or only the first view?

                            // S

                            Comment

                            Working...