LinkButton & Postback

Discussion in 'ASP .Net' started by Eric, May 13, 2008.

  1. Eric

    Eric Guest

    I have a linkbutton on a form that executes a script, it works fine except
    that it posts back to the calling form first. Is there a way to prevent
    this? I tried setting the PostBackURL property to the form the script
    launches but that resulted in some strange behavior.

    TIA
     
    Eric, May 13, 2008
    #1
    1. Advertising

  2. Eric

    Alex Meleta Guest

    Hi Eric,

    E.g. you can use this linkbutton .Attributes.Add("onclick", "return false")
    if you just need to run script in OnClientClick and prevent postback.

    Regards, Alex
    [TechBlog] http://devkids.blogspot.com

    E> I have a linkbutton on a form that executes a script, it works fine
    E> except that it posts back to the calling form first. Is there a way
    E> to prevent this? I tried setting the PostBackURL property to the
    E> form the script launches but that resulted in some strange behavior.
    E>
    E> TIA
    E>
     
    Alex Meleta, May 13, 2008
    #2
    1. Advertising

  3. Eric

    bruce barker Guest

    a LinkButton is an anchor with javascript added to do a postback. if you
    don't want to do a postback, don't use a link button, just use an anchor (or
    HyperLink). if you just want to call a javascript routine from an anchor, the
    usual trick is:

    <a href="#" onclick="myfunction(this);return false;" >Click me</a>
    or
    <a href="javascript:myfunction(this);" >Click me</a>

    note: some installs of IE fail to honor return false from an event, and must
    include code to cancel event bubbling.

    -- bruce (sqlwork.com)


    "Eric" wrote:

    > I have a linkbutton on a form that executes a script, it works fine except
    > that it posts back to the calling form first. Is there a way to prevent
    > this? I tried setting the PostBackURL property to the form the script
    > launches but that resulted in some strange behavior.
    >
    > TIA
    >
    >
    >
     
    bruce barker, May 13, 2008
    #3
  4. Eric

    eric Guest

    Thanks for the responses, the suggestions should do what I'm after.


    "Eric" <> wrote in message
    news:...
    >I have a linkbutton on a form that executes a script, it works fine except
    >that it posts back to the calling form first. Is there a way to prevent
    >this? I tried setting the PostBackURL property to the form the script
    >launches but that resulted in some strange behavior.
    >
    > TIA
    >
     
    eric, May 13, 2008
    #4
  5. Eric

    coolit 2011 Guest

    Re: Hi Eric,E.g. you can use this linkbutton .Attributes.

    Great !!!!
    it works.

    thank's :)

    > On Tuesday, May 13, 2008 11:28 AM Eric wrote:


    > I have a linkbutton on a form that executes a script, it works fine except
    > that it posts back to the calling form first. Is there a way to prevent
    > this? I tried setting the PostBackURL property to the form the script
    > launches but that resulted in some strange behavior.
    >
    > TIA



    >> On Tuesday, May 13, 2008 11:55 AM Mark Rae [MVP] wrote:


    >> Do you actually require a round-trip to the server, or do you just need to
    >> go to another page...?
    >>
    >>
    >> --
    >> Mark Rae
    >> ASP.NET MVP
    >> http://www.markrae.net



    >>> On Tuesday, May 13, 2008 1:25 PM brucebarke wrote:


    >>> a LinkButton is an anchor with javascript added to do a postback. if you
    >>> don't want to do a postback, don't use a link button, just use an anchor (or
    >>> HyperLink). if you just want to call a javascript routine from an anchor, the
    >>> usual trick is:
    >>>
    >>> <a href="#" onclick="myfunction(this);return false;" >Click me</a>
    >>> or
    >>> <a href="javascript:myfunction(this);" >Click me</a>
    >>>
    >>> note: some installs of IE fail to honor return false from an event, and must
    >>> include code to cancel event bubbling.
    >>>
    >>> -- bruce (sqlwork.com)
    >>>
    >>>
    >>> "Eric" wrote:



    >>>> On Tuesday, May 13, 2008 2:34 PM eric wrote:


    >>>> Thanks for the responses, the suggestions should do what I am after.



    >>>>> On Tuesday, May 13, 2008 11:39 PM Alex Meleta wrote:


    >>>>> Hi Eric,
    >>>>>
    >>>>> E.g. you can use this linkbutton .Attributes.Add("onclick", "return false")
    >>>>> if you just need to run script in OnClientClick and prevent postback.
    >>>>>
    >>>>> Regards, Alex
    >>>>> [TechBlog] http://devkids.blogspot.com
    >>>>>
    >>>>> E> I have a linkbutton on a form that executes a script, it works fine
    >>>>> E> except that it posts back to the calling form first. Is there a way
    >>>>> E> to prevent this? I tried setting the PostBackURL property to the
    >>>>> E> form the script launches but that resulted in some strange behavior.
    >>>>> E>
    >>>>> E> TIA
    >>>>> E>



    >>>>>> On Wednesday, July 08, 2009 1:18 PM ross wrote:


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



    >>>>>> Submitted via EggHeadCafe
    >>>>>> Custom task processes in SharePoint Designer Workflows
    >>>>>> http://www.eggheadcafe.com/tutorial...ocesses-in-sharepoint-designer-workflows.aspx
     
    coolit 2011, Nov 14, 2010
    #5
    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. Al Cohen

    Disable Linkbutton Before Postback?

    Al Cohen, Dec 19, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    10,919
    Vikesh Arora
    Dec 28, 2004
  2. =?Utf-8?B?QmVuamFtaW4gSm9sZGVyc21h?=

    LinkButton CommandArgument bound property loses value on postback

    =?Utf-8?B?QmVuamFtaW4gSm9sZGVyc21h?=, Aug 21, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,127
    =?Utf-8?B?QmVuamFtaW4gSm9sZGVyc21h?=
    Aug 21, 2004
  3. Sathyaish
    Replies:
    3
    Views:
    3,131
    Sathyaish
    Sep 8, 2005
  4. DavidC

    Keep LinkButton from postback

    DavidC, Feb 3, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    581
    DavidC
    Feb 3, 2010
  5. Sathyaish

    Linkbutton does not look like a linkbutton

    Sathyaish, Sep 8, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    201
    Sathyaish
    Sep 8, 2005
Loading...

Share This Page