LinkButton & Postback

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Eric

    #1

    LinkButton & Postback

    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


  • Mark Rae [MVP]

    #2
    Re: LinkButton & Postback

    "Eric" <asdf@a.comwrot e in message
    news:uR0J33QtIH A.1772@TK2MSFTN GP03.phx.gbl...
    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.
    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


    Comment

    • Alex Meleta

      #3
      Re: LinkButton &amp; Postback

      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

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


      Comment

      • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

        #4
        RE: LinkButton &amp; Postback

        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="myfunc tion(this);retu rn false;" >Click me</a>
        or
        <a href="javascrip t:myfunction(th is);" >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
        >
        >
        >

        Comment

        • eric

          #5
          Re: LinkButton &amp; Postback

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


          "Eric" <asdf@a.comwrot e in message
          news:uR0J33QtIH A.1772@TK2MSFTN GP03.phx.gbl...
          >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
          >

          Comment

          Working...