Ajax TabContainer ActiveTabChanged两次射击

时间:2012-05-18 13:03:51

标签: updatepanel tabcontainer

我无法弄清楚为什么我在ajax tabPanel上的ActiveTabChanged事件处理程序会触发两次。

任何人都应该能够将以下代码粘贴到新项目中(引用AjaxControlToolkit)来重现问题。

当用户点击标签时,tabchanged会被触发两次,从文本框的内容可以看出。你也可以通过调试和设置断点来看到它,它会被击中两次。

标记

<%@ 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>

代码隐藏

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 个答案:

没有答案