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. Advertising

  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
    DevelopMentor
    http://staff.develop.com/ballen



    > 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
     
    Brock Allen, Aug 8, 2005
    #2
    1. Advertising

  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
    Brock Allen wrote:
    > 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
    > DevelopMentor
    > http://staff.develop.com/ballen
    >
    >
    >
    > > 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 9, 2005
    #3
  4. Sameer

    Sameer Guest

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

    Thanks,
    Sameer

    Sameer wrote:
    > 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
    > Brock Allen wrote:
    > > 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
    > > DevelopMentor
    > > http://staff.develop.com/ballen
    > >
    > >
    > >
    > > > 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 11, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ItNerd
    Replies:
    0
    Views:
    537
    ItNerd
    Jul 6, 2004
  2. Lenny Shprekher
    Replies:
    0
    Views:
    2,334
    Lenny Shprekher
    Feb 23, 2005
  3. Sathyaish
    Replies:
    3
    Views:
    3,117
    Sathyaish
    Sep 8, 2005
  4. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    194
    Sathyaish
    Sep 8, 2005
  5. Pkenty
    Replies:
    0
    Views:
    407
    Pkenty
    May 28, 2004
Loading...

Share This Page