Ajax update panel & Double postback.

Last post 06-15-2009 9:53 PM by singlewind. 5 replies.

Sort Posts:

  • Ajax update panel & Double postback.

    01-07-2008, 8:53 AM
    • Member
      47 point Member
    • Mike55
    • Member since 02-02-2006, 3:47 PM
    • Posts 18

    I am using the ajax control toolkit update panel for a site. I have noted that when users use my site with the Mozilla browser and click on one of the buttons in the update panel that a double postback occurs. I have been unable to trace the source of this problem and I have been unable to replicate it in IE 6.0. Has anyone come across this problem before?

    Mike55.

  • Re: Ajax update panel & Double postback.

    01-07-2008, 10:51 AM
    • Star
      13,403 point Star
    • gt1329a
    • Member since 06-24-2002, 12:53 AM
    • Atlanta
    • Posts 2,212
    • ASPInsiders
      TrustedFriends-MVPs

    Are you able to reproduce the problem in FireFox yourself?  ASP.NET AJAX definitely works fine cross browser. 

    Encosia - ASP.NET, jQuery, AJAX, and more.

    Latest article: Using jQuery validation with ASP.NET WebForms
  • Re: Ajax update panel & Double postback.

    01-08-2008, 4:18 AM
    Answer
    • Member
      47 point Member
    • Mike55
    • Member since 02-02-2006, 3:47 PM
    • Posts 18

    I managed to locate the actual source of my problem; it was the following piece of vb.net/javascript code that caused the problem:

    'Prevent the user from double clicking on the save button.
        Private Sub PreventDoubleClick()
            Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
            sb.Append("if (typeof(Page_ClientValidate) == 'function') { ")
            sb.Append("if (Page_ClientValidate() == false) { return false; }} ")
            sb.Append("this.value = 'Please wait...';")
            sb.Append("this.disabled = true;")
            sb.Append(Page.GetPostBackEventReference(btnSave))
            sb.Append(";")
            btnSave.Attributes.Add("onclick", sb.ToString())
        End Sub

     Once this was removed all worked as per expected.  I had to find another way of working around the problem using the ajax UpdateProgress control.

     Mike55.

  • Re: Ajax update panel & Double postback.

    01-08-2008, 10:06 AM
    • Star
      13,403 point Star
    • gt1329a
    • Member since 06-24-2002, 12:53 AM
    • Atlanta
    • Posts 2,212
    • ASPInsiders
      TrustedFriends-MVPs

    The example here includes disabling a button trigger for the duration of a partial postback and then re-enabling it at the end.  Might be of use to you, in replacing that code. 

    Encosia - ASP.NET, jQuery, AJAX, and more.

    Latest article: Using jQuery validation with ASP.NET WebForms
  • Re: Ajax update panel & Double postback.

    01-23-2008, 3:04 PM
    • Member
      4 point Member
    • echo7x
    • Member since 05-19-2007, 8:08 PM
    • Posts 3

    I have had a similar problem with the UpdatePanel and double postbacks.  However these double postbacks occured in all browsers.  I was able to finally figure out the problem and it was caused by double wireing up of the controls to the code behind event. 

    For example:

    At the top of the page i had:

    AutoEventWireup="false"

    then my button:

    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />

    then the actual code behind

    Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click

    The problem was that the button had an OnClick specified, and in the code behind it also had the Handles btnSave.click.   By removing the Handles btnSave.click I was able to remove the extra postback.  You could also change the AutoEventWireup to True and then just remove the OnClick reference on the button.

    I hope this help

    echo7

  • Re: Ajax update panel & Double postback.

    06-15-2009, 9:53 PM
    • Member
      2 point Member
    • singlewind
    • Member since 02-20-2003, 9:37 PM
    • Australia
    • Posts 3

    Yes. This is bug only happend in firefox, when you enable or disable buttons in UpdatePanel.

    The golden rules is alaways disable button, or have some method handel the duplicate submit. 

    Yue Zhou
Page 1 of 1 (6 items)