Page view counter

Links and postbacks

Last post 11-19-2008 11:17 AM by davey_b. 5 replies.

Sort Posts:

  • Links and postbacks

    11-18-2008, 5:00 PM
    • Loading...
    • davey_b
    • Joined on 06-14-2004, 7:20 AM
    • Posts 69
    • Points 53

    Hello,

     I'm trying to have a popup window on my site without having the link I click on to open the popup cause a postback. I've tried server-side hyperlinks and linkbuttons (which both postback by default) setting the onclick event to return false and had enabled = false on both of the them but the postback still occured.

     Now I'm trying just a plain html anchor tag:

    <a onclick="return LoadHelp();">click me</a>

    With this javascript:

    function LoadHelp() {

    var newWin = window.open("scrhelp.aspx", "Help", "location=0,status=0,scrollbars=1,width=400,height=400");
    newWin.focus();
    return false;
    }

     And I still have a postback occurring. Any ideas as to what I can do to prevent the page from posting back?

     Thanks!

     

     

  • Re: Links and postbacks

    11-18-2008, 6:01 PM
    • Loading...
    • vlad322
    • Joined on 10-23-2007, 6:15 AM
    • Posts 98
    • Points 317

    try onclick="javascript:LoadHelp();"

    and forget the "return false" in the function

  • Re: Links and postbacks

    11-18-2008, 6:46 PM
    • Loading...
    • davey_b
    • Joined on 06-14-2004, 7:20 AM
    • Posts 69
    • Points 53

     Thanks for your replay vlad322. I thought for sure that would work, I actually LOL'd when I saw that I didn't have the "javascript:" in front of my function.

     When I load the page and click the link a postback occurs, however it doesn't postback on any subsequent clicks, it only postbacks once.

     

  • Re: Links and postbacks

    11-18-2008, 9:25 PM
    Answer
    • Loading...
    • x-format
    • Joined on 08-26-2008, 9:59 PM
    • Posts 266
    • Points 1,663

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script type="text/javascript">
    
    function LoadHelp() {
        var newWin = window.open("scrhelp.aspx", "Help", "location=0,status=0,scrollbars=1,width=400,height=400");
        newWin.focus();
    }
    
        </script>
    </head>
    <body>
        <a href="#" onclick="javascript: LoadHelp(); return false;">Click for help</a>
    </body>
    </html>
    
      

     

     no postback here...

     

  • Re: Links and postbacks

    11-19-2008, 10:58 AM
    Answer
    • Loading...
    • NC01
    • Joined on 08-26-2005, 3:33 PM
    • Posts 13,275
    • Points 71,391
    • TrustedFriends-MVPs

    According to his description, I think that something else is causing the PostBack, because it certainly does not happen for me. I tried server-side HyperLinks and LinkButtons setting the onclick event to return false and also tried anchor tags with no PostBacks whatsoever.

    NC...

  • Re: Links and postbacks

    11-19-2008, 11:17 AM
    • Loading...
    • davey_b
    • Joined on 06-14-2004, 7:20 AM
    • Posts 69
    • Points 53

     Thanks guys, I've made a new page here and don't have postbacks either. It must be something else on the page causing it.

    Cheers.

Page 1 of 1 (6 items)