Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6055311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:15:03+00:00 2026-05-23T08:15:03+00:00

I have a asp.net page where it has the following properties <asp:Button ID=btnBack runat=server

  • 0

I have a asp.net page where it has the following properties

<asp:Button ID="btnBack" runat="server" CssClass="Button" Text="< Back to Home" /></td>

And in the C# code file I am doing something like this

btnBack.Attributes.Add("onclick", "javascript:history.go(-1);return false");

The problem is it is not always returning me to the Home page but some other page..

Is there anyway I can add in this function the page where I want to navigate for instance (and I know its wrong but please see what i want to achieve)

    btnBack.Attributes.Add("onclick", "~/Home.aspx");

Something like that

I would appreciate your help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:15:04+00:00Added an answer on May 23, 2026 at 8:15 am

    The reason you aren’t always getting the behavior of moving back to the home page is because history.go(-1) just tells the browser to navigate back to the previous page that was loaded. It may not always be the home page.

    A simple solution from javascript is to change the location property which will trigger the broswer to load the URL supplied

    btnBack.OnClientClick = "window.location='http://www.google.com'";
    

    The OnClientClick will attach the javascript string to the onclick event in html markup for you. This is easier and cleaner IMO than something like
    btnBack.Attributes.Add("onclick", "window.location=~/Home.aspx"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Asp.net MVC 2 project. My start page has following link: http://localhost:2666/Home/Index?SomeID=4f62c452-4513-4dd0-b235-830d721815e4
I have a asp.net mvc site with a master page and it has following
I have an ASP.NET 3.5 page which has multiple span elements with ID containing
I have a ASP.NET web page that contains many textboxes. Each textbox has a
In my ASP.NET page, I have an input box that has to have the
I have an ASP.NET Web Forms web site. It has a page inside of
I have an ASP.Net website which has a remember me feature for Login page.
I have a ASP.NET web application which has more than 100 pages. Each page
I have a master page in my asp.net MVC project, which has code like
My ASP.NET page has following query string parameter: …?IDs=1000000012,1000000021,1000000013,1000000022&... Here IDs parameter will always

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.