Results 1 to 7 of 7

Thread: [RESOLVED] [2005] I have a Cancel button that wants to navigate back

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    Resolved [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.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    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.

  3. #3
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    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)")
    __________________
    Rate the posts that helped you

  4. #4

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    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.

  5. #5

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,562

    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 !

  6. #6
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    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")
    __________________
    Rate the posts that helped you

  7. #7
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [RESOLVED] [2005] I have a Cancel button that wants to navigate back

    you beat me
    __________________
    Rate the posts that helped you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width