How to issue "back" command from ASP.NET on the server

Posted on 2012-09-14
Last Modified: 2012-09-17
I have a web application written in classic ASP that  uses the following to return to a form if errors were found on it:

<a href="javascript:history.back(-1)">

This app is being modified to call an ASP.NET page to do some processing and display a report using Crystal Reports. If the user presses "Cancel" on the report I want to return to the previous page with the form data loaded.
Question by:dyarosh
    LVL 26

    Accepted Solution

    You can trigger javascript from an asp event by adding an attribute to the sending control.
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    Button2.Attributes.Add("onClick", "javascript:history.back(); return false;")
    End Sub
    Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
    End Sub

    Open in new window

    To capture/trap a crystal reports cancel print event isn't as straight forward:
    Detect Cancel From Crystal Report PrintSetup Dialogbox, but it is apparently doable.


    Author Closing Comment

    Thanks.  That gives me something to work with.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now