473,378 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Back button (.net) generated not working (Repost)

I created a couple of quick test pages and to my surprise, these do not work
either. When I click "Go Back" on test2.aspx, nothing happens. Ideas??
Surely I must be missing something obvious.....

Thanks
PAGE 1 - test.aspx
<%@ Page Language="VB" %>

<script runat="server">

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)

Response.Redirect("test2.aspx")

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form runat="server">

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Go" />

</form>

</body>

</html>


PAGE 2 - test2.aspx
<%@ Page Language="VB" %>

<script runat="server">

Sub page_load(ByVal Sender As Object, ByVal E As EventArgs)

Button1.Attributes.Add("onclick", "javascript:history.go(-1);")

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form runat="server">

<asp:Button ID="Button1" runat="server" Text="Go Back" />

</form>

</body>

</html>


**********************************************
Original post:
Somethinng odd is happening. I have a form button and on page load, I add a
javascript "back" function to this button. Like so:

btnCancel.Attributes.Add("onclick", "javascript:window.history.go(-1);")

<asp:Button ID="btnCancel" runat="server" Text="Cancel and go back." />

This generates the following html when rendered:

<input type="submit" name="btnCancel" value="Cancel and go back."
onclick="javascript:window.history.go(-1);" id="btnCancel" />

Yet, it doesn't work in IE6 or FF 1.5. Nothing happens. The page just
seems to post to itself. I've also tried changing the history.go value
to -2 and still get the same effect.

Any ideas? I'm using asp.net 2 (vb)

Thanks


Apr 21 '06 #1
2 2365
you go back button is doing two navigations. one the history request and the
other the original submit. you need to cancel the submit

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

or use an anchor, or regualr button, not submit button.

-- bruce (sqlwork.com)
"ShaneFowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:eI**************@TK2MSFTNGP02.phx.gbl...
I created a couple of quick test pages and to my surprise, these do not
work either. When I click "Go Back" on test2.aspx, nothing happens.
Ideas?? Surely I must be missing something obvious.....

Thanks
PAGE 1 - test.aspx
<%@ Page Language="VB" %>

<script runat="server">

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)

Response.Redirect("test2.aspx")

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form runat="server">

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Go"
/>

</form>

</body>

</html>


PAGE 2 - test2.aspx
<%@ Page Language="VB" %>

<script runat="server">

Sub page_load(ByVal Sender As Object, ByVal E As EventArgs)

Button1.Attributes.Add("onclick", "javascript:history.go(-1);")

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form runat="server">

<asp:Button ID="Button1" runat="server" Text="Go Back" />

</form>

</body>

</html>


**********************************************
Original post:
Somethinng odd is happening. I have a form button and on page load, I add
a javascript "back" function to this button. Like so:

btnCancel.Attributes.Add("onclick", "javascript:window.history.go(-1);")

<asp:Button ID="btnCancel" runat="server" Text="Cancel and go back." />

This generates the following html when rendered:

<input type="submit" name="btnCancel" value="Cancel and go back."
onclick="javascript:window.history.go(-1);" id="btnCancel" />

Yet, it doesn't work in IE6 or FF 1.5. Nothing happens. The page just
seems to post to itself. I've also tried changing the history.go value
to -2 and still get the same effect.

Any ideas? I'm using asp.net 2 (vb)

Thanks

Apr 21 '06 #2
Got it. Thanks a million. That never occurred to me (obviously).
"bruce barker (sqlwork.com)" <b_*************************@sqlwork.com> wrote
in message news:en**************@TK2MSFTNGP03.phx.gbl...
you go back button is doing two navigations. one the history request and
the other the original submit. you need to cancel the submit

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

or use an anchor, or regualr button, not submit button.

-- bruce (sqlwork.com)
"ShaneFowlkes" <sh**********@h-o-t-m-a-i-l.com> wrote in message
news:eI**************@TK2MSFTNGP02.phx.gbl...
I created a couple of quick test pages and to my surprise, these do not
work either. When I click "Go Back" on test2.aspx, nothing happens.
Ideas?? Surely I must be missing something obvious.....

Thanks
PAGE 1 - test.aspx
<%@ Page Language="VB" %>

<script runat="server">

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)

Response.Redirect("test2.aspx")

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form runat="server">

<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Go"
/>

</form>

</body>

</html>


PAGE 2 - test2.aspx
<%@ Page Language="VB" %>

<script runat="server">

Sub page_load(ByVal Sender As Object, ByVal E As EventArgs)

Button1.Attributes.Add("onclick", "javascript:history.go(-1);")

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Untitled Page</title>

</head>

<body>

<form runat="server">

<asp:Button ID="Button1" runat="server" Text="Go Back" />

</form>

</body>

</html>


**********************************************
Original post:
Somethinng odd is happening. I have a form button and on page load, I
add a javascript "back" function to this button. Like so:

btnCancel.Attributes.Add("onclick", "javascript:window.history.go(-1);")

<asp:Button ID="btnCancel" runat="server" Text="Cancel and go back." />

This generates the following html when rendered:

<input type="submit" name="btnCancel" value="Cancel and go back."
onclick="javascript:window.history.go(-1);" id="btnCancel" />

Yet, it doesn't work in IE6 or FF 1.5. Nothing happens. The page just
seems to post to itself. I've also tried changing the history.go value
to -2 and still get the same effect.

Any ideas? I'm using asp.net 2 (vb)

Thanks


Apr 21 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
0
by: Ivan K | last post by:
Hi, This is probably more of an Internet Explorer-related problem but I thought I would crosspost to microsoft.public.dotnet.framework.aspnet as this problem has probably occured for other...
1
by: Johan Nedin | last post by:
Hello! I am having a problem with the @OutputCache page directive and Web browser Back Buttons. Problem: After setting <%@ OutputCache Location="None" %> on my pages I get the "Warning!...
8
by: Shimon Sim | last post by:
Hi, Every time I write ASP.NET application I have the same problem - Back button on the browser is my enemy. I have to tell client avoid using "Back" button and if you use it make sure to refresh...
4
by: thehuby | last post by:
Is there any way of disabling the repost of information when a user hits the back button? Is the only way to do this to actually use some sort of redirect on the page receiving the initial post...
1
by: ShaneFowlkes | last post by:
Somethinng odd is happening. I have a form button and on page load, I add a javascript "back" function to this button. Like so: btnCancel.Attributes.Add("onclick",...
3
by: Ian Semmel | last post by:
Is there a way to get the Page_Load event to fire if the user clicks the Back button on the browser rather than clicking a hyperlink ?
8
by: Harvey Schmidlapp | last post by:
I have a fairly complex form (generated by means of an ASP 3 page). The form is used to define a query against a database. After running a query, the user hits their browser's back button and goes...
7
by: kashhere | last post by:
Hi all i am working on a site in which user need to be in same page when the user clicks on back button Its working in IE, Chrome but not in firefox in firefox when i click on the back...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.