RadTabStrip for ASP.NET

Server-side events Send comments on this topic.
See Also
Telerik RadTabStrip server-side > Server-side events

Glossary Item Box

Telerik RadTabStrip provides three server-side events - TabClick, TabCreated and TabDataBound.

TabClick - RadTabStrip exposes the AutoPostBack property. Setting the AutoPostBack property to True will force the tabstrip to postback upon each  tab selection. The server-side TabClick event is fired after a tabstrip postback. The instance of the clicked tab is passed to the TabClick event handler - you can obtain a reference to it using the eventArgs.Tab property.

TabCreated is fired every time a new tab is added to the RadTabStrip instance. TabCreated is not related to databinding and you cannot retrieve the DataItem of the tab in the TabCreated event handler. TabCreated is often useful in scenarios where you want to initialize all tabs - for example setting the ToolTip of each tab to be equal to the Text property.

TabDataBound is fired for each tab whenever you are databinding RadTabStrip (setting a DataSource and calling DataBind() explicitly or using declarative databinding through DataSourceID in ASP.NET 2.0). You can retrieve the tab being bound using the event arguments. The DataItem associated with the tab can be retrieved using the Tab.DataItem property. You need to cast the DataItem to the type of the datasource item you are binding to and then map fields from the DataItem to their respective properties in the Tab class. If you need to map Text/Value, you can use the RadTabStrip DataTextField and DataValueField properties instead of hooking TabDataBound.

Find examples of this functionality at www.telerik.com.

 

Example

The following example demonstrates the use of the TabClick event:

Clicked tab

ASPX Copy Code
<rad:RadTabStrip id="RadTabStrip1" runat="server" SelectedIndex="0" AutoPostBack="True">
   
<Tabs>
       
<rad:Tab Text="Corporate">
           
<Tabs>
               
<rad:Tab Text="About us">
                   
<Tabs>
                       
<rad:Tab Text="News"></rad:Tab>
                       
<rad:Tab Text="Team"></rad:Tab>
                   
</Tabs>
               
</rad:Tab>
               
<rad:Tab Text="Careers"></rad:Tab>
           
</Tabs>
       
</rad:Tab>
       
<rad:Tab Text="Services">
           
<Tabs>
               
<rad:Tab Text="Products"></rad:Tab>
               
<rad:Tab Text="Solutions"></rad:Tab>
               
<rad:Tab Text="Certifications"></rad:Tab>
           
</Tabs>
       
</rad:Tab>
       
<rad:Tab Text="Work">
           
<Tabs>
               
<rad:Tab Text="Clients"></rad:Tab>
               
<rad:Tab Text="Testimonials"></rad:Tab>
               
<rad:Tab Text="FAQ"></rad:Tab>
           
</Tabs>
       
</rad:Tab>
   
</Tabs>
</
rad:RadTabStrip>

<
div>
   
Clicked tab:
   
<asp:Label ID="Label1" runat="server" ></asp:Label>
</
div>

 

C# Copy Code
private void InitializeComponent()
{
   
this.RadTabStrip1.TabClick += new Telerik.WebControls.TabStripEventHandler(this.RadTabStrip1_Click);
   
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void RadTabStrip1_Click(object sender, Telerik.WebControls.TabStripEventArgs e)
{
   Label1.Text = e.Tab.Text;
}

 

See Also