Ajax TabContainer ActiveTabChanged Firing Twice

1.9k Views Asked by At

I can't figure out why my event handler for ActiveTabChanged on an ajax tabPanel is firing twice.

Anyone should be able to paste the following code in a new project (with a reference to AjaxControlToolkit) to reproduce the problem.

When user clicks a tab, tabchanged gets fired twice, as can be seen from the contents of the textboxes. You can also see it by debugging and setting a breakpoint, which gets hit twice.

Markup

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="Project1.WebForm1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajax" %>

<!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 runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager runat="server" ID="ScriptManager1" 
                            EnablePartialRendering="true" 
                            SupportsPartialRendering="true" 
                            ScriptMode="Release"
                            LoadScriptsBeforeUI ="true">
      </asp:ScriptManager>
      <asp:UpdatePanel ID="up" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
             <ajax:TabContainer id="TabContainer" runat="server"  EnableViewState="true" AutoPostBack="true">
                    <ajax:TabPanel id="tab1" runat="server"  HeaderText="Tab1">
                        <ContentTemplate>
                            <asp:TextBox runat='server' ID="txtTab1" Text="" Width="600px"></asp:TextBox>
                        </ContentTemplate>
                    </ajax:TabPanel>
                     <ajax:TabPanel id="tab2" runat="server"  HeaderText="Tab2">
                        <ContentTemplate>
                            <asp:TextBox runat='server' ID="txtTab2" Text=""  Width="600px"></asp:TextBox>
                        </ContentTemplate>
                    </ajax:TabPanel>
              </ajax:TabContainer>

            </ContentTemplate>
      </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

Codebehind

Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Private Sub TabContainer_ActiveTabChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabContainer.ActiveTabChanged

        Me.txtTab1.Text = Me.txtTab1.Text & "_changed"
        Me.txtTab2.Text = Me.txtTab2.Text & "_changed"
    End Sub
End Class
0

There are 0 best solutions below