Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AjaxControlToolkit TabContainer ActiveTabChanged event fired twice when UpdatePanel and ToolkitScriptManager is used?

I recently upgrade this configuration:

ASP.NET 2.0
AjaxControlToolkit, 1.0.20229.0
System.Web.Extensions, Version=2.0.0.0

To

ASP.NET 3.5
System.Web.Extensions, Version=3.5.0.0
AjaxControlToolkit , Version=3.5.40412.0

I have the following structure:

<asp:ToolkitScriptManager ID="PageScriptManager" runat="server">  
</asp:ToolkitScriptManager>  
    <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always">
        <ContentTemplate>
         <ajaxToolkit:TabContainer 
              OnActiveTabChanged="TabContainerCarga_ActiveTabChanged"
              AutoPostBack="True">
                        <ajaxToolkit:TabPanel 
                            ID="tabRelatorios"
                            runat="server"
                            HeaderText="Relat&#243;rios">
                                <ContentTemplate>
                                    <CustomUserControl:relatorios id="CustomControl" Visible="False" runat="server" />                                                      
                                </ContentTemplate>
                                      <Triggers>
                                        <asp:PostBackTrigger ControlID="CustomControl" />
                                      </Triggers>
                            </ajaxToolkit:TabPanel>
                  <ajaxToolkit:TabPanel ... />
                  <ajaxToolkit:TabPanel ... />
                  <ajaxToolkit:TabPanel ... />
                  <ajaxToolkit:TabPanel ... />

All the has the same first structure. At the serverside code, I have:

protected void TabContainerCarga_ActiveTabChanged(object sender, EventArgs e)
{
   //handles TabPanels show/hide and fill up forms grids.
}

CustomControl has a grid which has some post-backs to perform operation like adding and removing records. When CustomControl loads it fills two <asp:DataGrid /> components.

  1. <asp:DataGrid /> load a list with some text box, which the user may fill out and press a button to add records.
  2. <asp:DataGrid /> show any entered information. To history purposes.

The strange known behavior is, it actually fire ActiveTabChanged twice. In the first time, it act like I'm loading the CustomControl state for the first time and them goes do the event.

I can't use some solution I've seen like set isFormLoaded flag or even fire a javascript postBack function.

I think about placing a IsLoaded flag structured in a ViewState inside the control. And restart it after any fired event inside the custom control.

What do you think about this and there is any solution arround?

like image 387
Eduardo Xavier Avatar asked Dec 01 '25 04:12

Eduardo Xavier


1 Answers

I couldn't solve this problem because it comes from the internal mechanics of this component. I wouldn't go through that jungle. So I asked a designer to draw cool tabs for me and wrote my own tab control using AJAX and Rest Services style. That's it! The behavior I wanted now I have it and works pretty nice now; controllable and loads less JavaScript code into the client machine. Stop using that shit!

like image 147
Eduardo Xavier Avatar answered Dec 02 '25 18:12

Eduardo Xavier