We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to add UserControl inside Tab from code behind?

Description

You can create a Tab control with UserControl in ContentSection and add Tab items from code behind. This helps you to load content with multiple controls inside a tab and provides you a clear structured code.

Solution

In order to add the web user control with the user defined structure with multiple controls and elements to a Tab, you can use the LoadControl() method of ASP UserControl class in code behind. Refer to the following steps to create a Tab items from code behind and map user control from code behind.

  • Create a Tab element in the ASPX page and required UserControl pages for your application.
  • Create an instance for UserControl and pass the virtual path to the LoadControl() method.
  • Declare a Syncfusion TabItem instance and define its ID and Text.
  • By using the ContentSection property of the TabItem, add the created UserControl instance to corresponding tab item
  • Finally, add the tab items to the Tab by using Items.Add() method.

Refer to the following code examples to add UserControl from code behind.

ASPX

 

CS

 

ASCX

The following screenshot displays the Tab with the loaded user control and items created from code behind.

Figure 1: Tab with UserControl and Tab items added from code behind

Article ID: Published Date: Last Revised Date: Platform: Control: Product Version:
3232 01/13/2015 01/13/2015 ASP.NET Web Forms Tab 12.4.0.24
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.