Stop postback/refresh using a button...

Discussion in 'ASP .Net' started by Matthew Wells, Mar 1, 2008.

  1. Hello.

    I'm trying to use an asp - not html - button without having a postback or a
    screen refresh. I've tried turning off "CausesValidation" and
    "UseSubmitBehavior" and I still get a screen refresh - which makes me think
    I'm doing a postback. I've also tried "return false" in both the onclick
    and OnClientClick events. No Luch. Can I use the onclick or OnClientClick
    (or something else) to fire a javascritpt function and then stop?

    Thanks.

    Matthew Wells
     
    Matthew Wells, Mar 1, 2008
    #1
    1. Advertising

  2. I found the answer myself. Make sure UseSubmitBehavior" is True. Do NOT
    use OnClick as that requires a server postback. Use OnClientClick and make
    sure to return 'false'. It does not have to be in a response to a "confirm"
    box, just "return false;". You can do anything in between that doesn't
    cause a postback.


    "Matthew Wells" <> wrote in message
    news:...
    > Hello.
    >
    > I'm trying to use an asp - not html - button without having a postback or
    > a screen refresh. I've tried turning off "CausesValidation" and
    > "UseSubmitBehavior" and I still get a screen refresh - which makes me
    > think I'm doing a postback. I've also tried "return false" in both the
    > onclick and OnClientClick events. No Luch. Can I use the onclick or
    > OnClientClick (or something else) to fire a javascritpt function and then
    > stop?
    >
    > Thanks.
    >
    > Matthew Wells
    >
    >
     
    Matthew Wells, Mar 1, 2008
    #2
    1. Advertising

  3. Matthew Wells

    Paul Ireland Guest

    Stop postback/refresh using a button

    You are required to be a member to post replies. After logging in or becoming a member, you will be redirected back to this page.



    Posted as a reply to:

    Stop postback/refresh using a button...

    Hello

    I'm trying to use an asp - not html - button without having a postback or a
    screen refresh. I've tried turning off "CausesValidation" and
    "UseSubmitBehavior" and I still get a screen refresh - which makes me think
    I'm doing a postback. I've also tried "return false" in both the onclick
    and OnClientClick events. No Luch. Can I use the onclick or OnClientClick
    (or something else) to fire a javascritpt function and then stop

    Thanks

    Matthew Well


    EggHeadCafe - Software Developer Portal of Choice
    WCF Workflow Services Using External Data Exchange
    http://www.eggheadcafe.com/tutorial...a-6dafb17b6d74/wcf-workflow-services-usi.aspx
     
    Paul Ireland, Sep 16, 2009
    #3
  4. Matthew Wells

    Ralph Guest

    Re: Stop postback/refresh using a button

    <Paul Ireland> wrote in message
    news:...
    > You are required to be a member to post replies. After logging in or
    > becoming a member, you will be redirected back to this page.
    >
    >
    >
    > Posted as a reply to:
    >
    > Stop postback/refresh using a button...
    >
    > Hello.
    >
    > I'm trying to use an asp - not html - button without having a postback or
    > a
    > screen refresh. I've tried turning off "CausesValidation" and
    > "UseSubmitBehavior" and I still get a screen refresh - which makes me
    > think
    > I'm doing a postback. I've also tried "return false" in both the onclick
    > and OnClientClick events. No Luch. Can I use the onclick or
    > OnClientClick
    > (or something else) to fire a javascritpt function and then stop?
    >
    > Thanks.
    >
    > Matthew Wells
    >
    >
    > EggHeadCafe - Software Developer Portal of Choice
    > WCF Workflow Services Using External Data Exchange
    > http://www.eggheadcafe.com/tutorial...a-6dafb17b6d74/wcf-workflow-services-usi.aspx


    the following should work in the aspx to prevent postback.



    <asp:Button ID="Button1" runat="server" OnClientClick="return false;"
    onclick="Button1_Click" Text="Button" />
     
    Ralph, Sep 16, 2009
    #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. brian lanning
    Replies:
    0
    Views:
    617
    brian lanning
    Jul 29, 2003
  2. gerry
    Replies:
    3
    Views:
    474
    Walter Wang [MSFT]
    Nov 23, 2007
  3. Wael_Bakr

    stop postback in postback events for server controls ??

    Wael_Bakr, Nov 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    517
    Wael_Bakr
    Nov 30, 2005
  4. Stop Postback in image button

    , Jul 26, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    266
    Alessandro Zifiglio
    Jul 26, 2006
  5. Jawahar Rajan
    Replies:
    1
    Views:
    307
    Adrienne
    Oct 1, 2003
Loading...

Share This Page