UpdatePanels causing Coolite event handlers to fire multiple times

  1. #1

    UpdatePanels causing Coolite event handlers to fire multiple times

    In this scenario, I don't have any Coolite controls within an UpdatePanel, but I DO have other standard controls, i.e. GridView, inside of an UpdatePanel.

    I noticed that after an UpdatePanel postback, my AjaxEvent handlers were firing multiple times. It appears that the Coolite ScriptManager re-renders itself and all event handlers on an async postback if the scriptmanager isn't in the <head> section of the page.

    Voila! Moving the ScriptManager inside the <head> section fixed my problems!

    Hope this helps anyone else having similar problems!
  2. #2

    RE: UpdatePanels causing Coolite event handlers to fire multiple times

    Hi Mark.Cooke,

    Any chance you could put together a simplified .aspx code sample demonstrating this scenario? I would be really interested in testing exactly what you're testing with.




    Geoffrey McGill
    Founder
  3. #3

    RE: UpdatePanels causing Coolite event handlers to fire multiple times

    Hi,

    me too I'm interested in this, although because of same name, I didn't understand wich scriptmanager: ASP or Ext?

    Thanx

    Matteo
  4. #4

    RE: UpdatePanels causing Coolite event handlers to fire multiple times



    So I finally got around to putting together an example that demonstrates the problem.
    Basically, I have an AjaxEvent on the "Save" button that triggers an UpdatePanel to refresh, but the Coolite ScriptManager init is being included in the UpdatePanel response, so the next time the "Show Dialog" button is clicked, it's firing the AjaxEvent twice, then 3x, 4x, etc.

    <%@ Page Language="C#" %>
    
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    <script runat="server">
        protected void btnShow_Click(object sender, AjaxEventArgs e)
        {
            this.dlgTest.Show();
        }
        
        protected void btnSave_Click(object sender, AjaxEventArgs e)
        {
            this.dlgTest.Hide();
        }
    
    
        protected void btnUpdateStatus_Click(object sender, EventArgs e)
        {
            lblStatus.Text += string.Format("<br />Save button clicked: {0}", DateTime.Now);
        }
    </script>
    
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            
            <asp:Button ID="btnShow" runat="server" Text="Show Dialog" />
            
            <p>Status:</p>
            <asp:UpdatePanel ID="upReports" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Button ID="btnUpdateStatus" runat="server" style="display:none;" &#111;nclick="btnUpdateStatus_Click" />
                    <asp:Label ID="lblStatus" runat="server" />
                </ContentTemplate>
            </asp:UpdatePanel>
            
            
            <ext:ScriptManager ID="extScriptMgr" runat="server" CleanResourceUrl="true" StateProvider="PostBack">
                <CustomAjaxEvents>
                    <ext:AjaxEvent Target="btnShow" OnEvent="btnShow_Click" Success="alert('return from btnShow AjaxEvent');">
                        <EventMask Target="This" MinDelay="500" />
                    </ext:AjaxEvent>
                </CustomAjaxEvents>
            </ext:ScriptManager>
            
            <ext:Window ID="dlgTest" runat="server" Show&#111;nload="false" CloseAction="Hide" Width="300" Height="200">
                <Content>
                    Every time the Save button is clicked, notice the window alert is fired an extra time when you click on Show Dialog.
                </Content>
                <Buttons>
                    <ext:Button ID="btnSave" runat="server" Text="Save">
                        <AjaxEvents>
                            <Click OnEvent="btnSave_Click" Success="#{btnUpdateStatus}.dom.click();">
                                <EventMask Target="Parent" Msg="Saving..." MinDelay="500" />
                            </Click>
                        </AjaxEvents>
                    </ext:Button>
                    <ext:Button ID="btnCancel" runat="server" Text="Cancel">
                        <Listeners>
                            <Click Handler="#{dlgTest}.hide();" />
                        </Listeners>
                    </ext:Button>
                </Buttons>
            </ext:Window>        
        
    
        </form>
    </body>
    </html>
  5. #5

    RE: UpdatePanels causing Coolite event handlers to fire multiple times

    Hi Mark.Cooke.

    I'm just wonder if you know how to solve this "issue" with de AjaxEvents firing multiple times, when having a Master Page (and a Coolite Script Manager inside it) ?

    When I move the Coolite Script Manager to the <head> section of the Master Page, the "child" pages stop working.

    Regards !

    Alfonso Penunuri.

Similar Threads

  1. [CLOSED] Event handler before direct event handlers
    By matejgolob in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jun 08, 2012, 2:31 PM
  2. Replies: 6
    Last Post: Apr 05, 2012, 4:23 PM
  3. [CLOSED] Click event launched several times
    By jeybonnet in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Dec 23, 2011, 8:31 AM
  4. Gridpanel is appearing multiple times
    By Mr.Techno in forum 1.x Help
    Replies: 4
    Last Post: Jun 22, 2011, 11:35 AM
  5. Calling AddScript multiple times?
    By dbassett74 in forum 1.x Help
    Replies: 4
    Last Post: May 14, 2009, 7:27 PM

Posting Permissions