TabContainer :
To present tabbed UI , TabControl can be used.If you have a page that has lot of content to present then we can break it into tabs.TabContainer contains many TabPanels each of which represents a tab.
Important attributes of TabContainer control are :
OnActiveTabChanged : This event is fired when active (current ) tab is changed.It is a server side event.
OnClientActiveTabChanged : It is also fired when current tab is changed.It is client side event. we need to write javascript for this.
Scrollbar : used to specify alignment of Scrollbar for tab container.It takes Horizontal , vertical , both , none and auto values.
TabPanel :
TabPanel has HeaderTemplate and Content Template.Header Template is optional and can be used to specify header.
We can use either HeaderTemplate or HeaderText attribute to specify header for a tab.
All the content under a tab should be specified within ContentTemplate tag.
TabContainer Example :
This example shows how to create tabs using TabContainer control. We can also write some events when tabs are changed which I will illustrate in next example.
Aspx Code :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TabContainer.aspx.cs" Inherits="Ajax_Controls_Examples_TabContainer" %> <!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"> <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" ScrollBars="Horizontal" > <ajaxToolkit:TabPanel ID="TabPanel2" runat="server"> <ajaxToolkit:TabPanel ID="TabPanel3" runat="server"> <ajaxToolkit:TabPanel ID="TabPanel4" runat="server"> </ajaxToolkit:TabContainer> |
Output:
Another TabContainer Example with events when tab is changed . For this we need to make use of “OnActiveTabChanged” or “OnClientActiveTabChaned” event of this control.
Aspx Code :
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TabContainer.aspx.cs" Inherits="Ajax_Controls_Examples_TabContainer" %> <!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"> |
Code Behind:
using System; public partial class Ajax_Controls_Examples_TabContainer : System.Web.UI.Page } } |
Output :
No comments:
Post a Comment