LinkButton click, refresh the page

Discussion in 'ASP .Net' started by Sameer, Aug 8, 2005.

  1. Sameer

    Sameer Guest

    I have a webpage that has a link button. This link button on click
    opens up a new page.
    This is what is happening:

    1. Load the web page.
    2. Click on the link.
    3. Refresh the web-page.
    Result: The webpage gets refreshed and the link buttons onClick event
    is fired.

    However, if I just load the web-page and without clicking on the link
    button, refresh the web-page it does not fire the onClick event of the
    link button.

    I don't want the link button's onClick event to fire when I refresh the
    web-page. How can we prevent this from happening?

    Thanks and Regards,
    Sameer
     
    Sameer, Aug 8, 2005
    #1
    1. Advertisements

  2. Sameer

    Brock Allen Guest

    By clicking the link you are posting back the page. Once you've posted back
    the page and the user hits refresh or F5 you're asking the browser to do
    whatever it did last (which is a post). To fix this, have your LinkButton's
    OnClick do a Response.Redirect(Request.Path).
     
    Brock Allen, Aug 8, 2005
    #2
    1. Advertisements

  3. Sameer

    Sameer Guest

    The link button's onClick event does a window.open (Javascript) and
    writes it to the response object. If I do a Response.Redirect, the
    window.open action is lost.

    Seems like I need some other way of doing the window.open and not using
    the Response.Write to write the window.open javascript to it. Not
    really sure how to do it...

    Thanks,
    Sameer
     
    Sameer, Aug 9, 2005
    #3
  4. Sameer

    Sameer Guest

    Just changed the link button to hyperlink and it works fine now.

    Thanks,
    Sameer
     
    Sameer, Aug 11, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.