Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Go back to previous page

Go back to previous page

Scheduled Pinned Locked Moved ASP.NET
htmlcomhelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isaii
    wrote on last edited by
    #1

    Hello everyone, I have webpage1 that sends email when button1 is click. I want to go back to previous page once button1 is click so I use history.back code. Below is my sample code for your reference. If Page.IsValid And SaveIssue() Then Dim msg As New MailMessage msg.To = Test@dc.com msg.From = "ACSC@noreply.com" msg.Subject = "Reply- " & txtTitle.Text msg.Body = "Hello" msg.BodyFormat = MailFormat.Html SmtpMail.SmtpServer = "abc.com" SmtpMail.Send(msg) msg = Nothing btnDone.Attributes.Add("onClick", "history.back(); return false;" End If My problem is, it will only work on the second time you will click button1. Kindly advise for the right code. Thanks in advance.

    _ C 2 Replies Last reply
    0
    • I isaii

      Hello everyone, I have webpage1 that sends email when button1 is click. I want to go back to previous page once button1 is click so I use history.back code. Below is my sample code for your reference. If Page.IsValid And SaveIssue() Then Dim msg As New MailMessage msg.To = Test@dc.com msg.From = "ACSC@noreply.com" msg.Subject = "Reply- " & txtTitle.Text msg.Body = "Hello" msg.BodyFormat = MailFormat.Html SmtpMail.SmtpServer = "abc.com" SmtpMail.Send(msg) msg = Nothing btnDone.Attributes.Add("onClick", "history.back(); return false;" End If My problem is, it will only work on the second time you will click button1. Kindly advise for the right code. Thanks in advance.

      _ Offline
      _ Offline
      _mubashir
      wrote on last edited by
      #2

      History.back to me, is not the right way as I found it useless in firefox. So Simply navigate to your WebForm1.aspx like btnDone.Attributes.Add("onClick", "window.location = 'WebForm1.aspx'; return false;"


      Mubashir Software Architect Storan Technologies Inc, USA Every job is a self portrait of the person who did it.

      I 1 Reply Last reply
      0
      • _ _mubashir

        History.back to me, is not the right way as I found it useless in firefox. So Simply navigate to your WebForm1.aspx like btnDone.Attributes.Add("onClick", "window.location = 'WebForm1.aspx'; return false;"


        Mubashir Software Architect Storan Technologies Inc, USA Every job is a self portrait of the person who did it.

        I Offline
        I Offline
        isaii
        wrote on last edited by
        #3

        Hello, Its because I have some control in my previous page that I want to retain the value, thats why I just simply use history.back. Do you have any suggestion?

        C 1 Reply Last reply
        0
        • I isaii

          Hello everyone, I have webpage1 that sends email when button1 is click. I want to go back to previous page once button1 is click so I use history.back code. Below is my sample code for your reference. If Page.IsValid And SaveIssue() Then Dim msg As New MailMessage msg.To = Test@dc.com msg.From = "ACSC@noreply.com" msg.Subject = "Reply- " & txtTitle.Text msg.Body = "Hello" msg.BodyFormat = MailFormat.Html SmtpMail.SmtpServer = "abc.com" SmtpMail.Send(msg) msg = Nothing btnDone.Attributes.Add("onClick", "history.back(); return false;" End If My problem is, it will only work on the second time you will click button1. Kindly advise for the right code. Thanks in advance.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Add it in the aspx, not the code behind. I'd say it's only working the second time because the first time your if statement fails.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          I 1 Reply Last reply
          0
          • I isaii

            Hello, Its because I have some control in my previous page that I want to retain the value, thats why I just simply use history.back. Do you have any suggestion?

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Then it depends on if you care about FireFox. If you do, find out how to do it in FF and write script that calls the right thing.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            1 Reply Last reply
            0
            • C Christian Graus

              Add it in the aspx, not the code behind. I'd say it's only working the second time because the first time your if statement fails.

              Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              I Offline
              I Offline
              isaii
              wrote on last edited by
              #6

              Do you mean, i'll put the history.back on the onclick event of my button?

              C 1 Reply Last reply
              0
              • I isaii

                Do you mean, i'll put the history.back on the onclick event of my button?

                C Offline
                C Offline
                Christian Graus
                wrote on last edited by
                #7

                Yes, if you add properties to a server control and the server does not recognise them, they get passed through to the client verbatim.

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                I 1 Reply Last reply
                0
                • C Christian Graus

                  Yes, if you add properties to a server control and the server does not recognise them, they get passed through to the client verbatim.

                  Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  I Offline
                  I Offline
                  isaii
                  wrote on last edited by
                  #8

                  Hi.. but got an error Compiler Error Message: BC30456: 'history' is not a member of 'ASP.webform1_aspx'.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups