Looking for a way to move back to the previous page in ASP.NET

Posted on 2008-11-16
Last Modified: 2012-05-05

I need a function or a method I could use with a clickable button to move the user back to the previous page, whatever that page maybe - some thing like the back and forward arrows in MS Internet explorer.

Thank you
Question by:tariqanis
    LVL 7

    Expert Comment

    this.btnBack.OnClientClick = "javascript:window.history.go(-1);";

    Assuming you have a btnBack on the page...

    Author Comment

    Hi aherps:

    I tried your code in the manner below, but the page is posted back to itself.
    <asp:ImageButton ID="Phone" runat="server" Width="45pt"
         ImageUrl="~/UploadImages2/phone.jpg" OnClientClick ="javascript:window.history.go(-1);";  />

    Author Comment

    Hi again aherps:

    I found this on the internet and it worked:

    OnClientClick="javascript:window.history.back();return false;"
    How about a butto that moves to the next (forward) page ?

    LVL 1

    Accepted Solution

    OnClientClick="javascript:window.history.forward();return false;"
    Hope this helps...
    LVL 1

    Expert Comment

    OnClientClick="javascript:window.history.go(1);return false;"

    Author Comment

    Thank you.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    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…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    755 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

    24 Experts available now in Live!

    Get 1:1 Help Now