ComponentOne Expander for ASP.NET AJAX: Expander for ASP.NET AJAX Task-Based Help > Creating a C1Expander in Code

Creating a C1Expander in Code

Creating a C1Expander control in code is fairly simple. In the following steps you'll add a PlaceHolder control to the page, add an import statement, add and customize the C1Expander, and add the control to the PlaceHolder.

Complete the following steps:

1.   In Design view, navigate to the Visual Studio Toolbox and add a PlaceHolder control to your page.

2.   Double-click the page to create the Page_Load event and switch to Code view.

3.   Add the following statement to the top of the Code Editor to import the appropriate namespace:

      Visual Basic

Imports C1.Web.UI.Controls.C1Expander

      C#

using C1.Web.UI.Controls.C1Expander;

4.   Add the following code to the Page_Load event to create and customize the C1Expander control.

      Visual Basic

' Create a new C1Expander.

Dim C1E As New C1Expander

' Set the control's size, appearance, and content.

C1E.VisualStyle = "Office2007Blue"

C1E.Height = 200

C1E.Width = 200

C1E.ContentUrl = "http://www.wikipedia.com/"

' Add the C1Expander to the PlaceHolder control.

PlaceHolder1.Controls.Add(C1E)

      C#

// Create a new C1Expander.

C1Expander C1E = new C1Expander();

// Set the control's size, appearance, and content.

C1E.VisualStyle = "Office2007Blue";

C1E.Height = 200;

C1E.Width = 200;

C1E.ContentUrl = "http://www.wikipedia.com/";

// Add the C1Expander to the PlaceHolder control.

PlaceHolder1.Controls.Add(C1E);

What You've Accomplished

Run your application and observe that the C1Expander control was created and displays external content:

 


Send comments about this topic to ComponentOne.
Copyright © ComponentOne LLC. All rights reserved.