TabContainer实现服务器端回传

TabContainer要实现服务器端回传,出来在后台实现 OnActiveTabChanged 事件外,还需要在前台实现 OnClientActiveTabChanged 事件,这是关键。


<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true">
    
<contenttemplate>
        
<ajaxToolkit:TabContainer runat="server" ID="Tabs" Height="480px" Width="100%" 
            OnClientActiveTabChanged
="activeTabChanged"
            OnActiveTabChanged
="Tabs_ActiveTabChanged">
            
<ajaxToolkit:TabPanel runat="Server" ID="Panel1" HeaderText="我的消息">
                
<ContentTemplate>
                ***
                
</ContentTemplate>
            
</ajaxToolkit:TabPanel>
            
<ajaxToolkit:TabPanel runat="Server" ID="Panel2" HeaderText="已发消息">
                
<ContentTemplate>
                    ***
                
</ContentTemplate>
            
</ajaxToolkit:TabPanel>
        
</ajaxToolkit:TabContainer>
    
</contenttemplate>
    
<triggers>
        
<asp:AsyncPostBackTrigger ControlID="Tabs" EventName="ActiveTabChanged" />
    
</triggers>
</asp:UpdatePanel>

<script language="javascript" type="text/jscript">
function activeTabChanged(sender, e) 

    __doPostBack('
<%= Tabs.ClientID %>', sender.get_activeTabIndex()); 
}

</script>


后台.cs代码:

protected   void  Tabs_ActiveTabChanged( object  sender, EventArgs e)
{
    
switch (Tabs.ActiveTabIndex)
    
{
        
case 0:
            BindGrid();
            
break;
        
case 1:
            BindGrid2();
            
break;
        
case 2:
            Message.Text 
= "";
            
break;
        
default:
            
break;
    }

}

你可能感兴趣的:(contain)