ComponentOne Expander for ASP.NET Web Forms
Task-Based Help / Creating a C1Expander in Code
In This Topic
    Creating a C1Expander in Code
    In This Topic

    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:

      To write code in Visual Basic

      Visual Basic
      Copy Code
      Imports C1.Web.Wijmo.Controls.C1Expander
      

      To write code in C#

      C#
      Copy Code
      using C1.Web.Wijmo.Controls.C1Expander;
      
    4. Add the following code to the Page_Load event to create and customize the C1Expander control.

      To write code in Visual Basic

      Visual Basic
      Copy Code
      ' 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)
      

      To write code in C#

      C#
      Copy Code
      // 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:

    See Also