[RESOLVED] [2005] I have a Cancel button that wants to navigate back
I thought this code would make that happen:
Code:
Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
' Dim script As String = "<script>history.go(-1);</script>"
' Page.RegisterStartupScript("backupPage", script)
ClientScript.RegisterClientScriptBlock( _
Me.GetType, _
"GoinBack", _
"<script type='text/JavaScript'>history.go(-1)</script>")
End Sub
Nothing is happening. I am not going back, there is no javascript error, it just posts back and stays on the same page. Do you see what's wrong? Thanks.
Re: [2005] I have a Cancel button that wants to navigate back
I'm sorry. I actually just realized I want to call it at the client because why would I post back to the server just to navigate back? I'll try it there.
Re: [2005] I have a Cancel button that wants to navigate back
not sure whats worng with above but i would do this way
in page load event
Code:
btnCancel.Attributes.Add("onclick", "javascript:history.go(-1)")
Re: [2005] I have a Cancel button that wants to navigate back
That's not working. Not only does it post back, but it is not navigating back. Same as my original problem.
Re: [2005] I have a Cancel button that wants to navigate back
All better:
Code:
btnCancel.Attributes.Add("onclick", "javascript:history.go(-1);return false")
Thanks, riteshjain1982 - as helpful as always :) !
Re: [RESOLVED] [2005] I have a Cancel button that wants to navigate back
opps i forgot to add return false.
Code:
btnCancel.Attributes.Add("onclick", "javascript:history.go(-1);return false")
Re: [RESOLVED] [2005] I have a Cancel button that wants to navigate back