ComponentOne MultiPage for ASP.NET AJAX: MultiPage for ASP.NET AJAX Task-Based Help > Adding and Manipulating Page Content > Adding Arbitrary Controls to a Page

Adding Arbitrary Controls to a Page

You can add arbitrary controls to each of your C1MultiPage's pages using a simple drag-and-drop operation, HTML, or code. In this topic, you will create a C1MultiPage control with two pages and then add an arbitrary control to each page in Design view, in Source view, and in code

Adding Arbitrary Controls in Design View

To add arbitrary controls, complete these steps:

1.   Click C1MultiPage's smart tag () to open the C1MultiPage Tasks menu and select MultiPage Designer.

      The C1MultiPage Designer Form appears.

2.   Use the Add Child Item button  to add two pages to your C1MultiPage.

3.   Click OK to close the C1MultiPage Designer Form.

4.   Select a Button control from the Visual Studio Toolbox and drag it onto the C1MultiPage control.

5.   Click C1MultiPage's smart tag ()  and select Move to next page to bring the second page into focus.

           

 

6.   Select a TextBox from the Toolbox window and drag it onto the C1MultiPage control.

7.   Run the project.

Adding Arbitrary Controls in Source View

To add arbitrary controls, complete these steps:

1.   Click C1MultiPage's smart tag () to open the C1MultiPage Tasks menu and then select MultiPage Designer.

      The C1MultiPage Designer Form appears.

2.   Use the Add Child Item button  to add two pages to your C1MultiPage.

3.   Click OK to close the C1MultiPage Designer Form.

4.   Click the Source tab to enter Source view.

5.   Locate the  <cc1:C1PageView> tags for PageView1 and place the following tag between them:

 

<asp:Button ID="Button1" runat="server" Text="Button" />

 

6.   Locate the <cc1:C1PageView> tags for PageView2 and place the following tag between them:

 

<asp:TextBox ID="TextBox2" runat="server" />

7.   Run the project.

Adding Arbitrary Controls in Code

To add arbitrary controls, complete these steps:

1.   Click C1MultiPage's smart tag  ()  to open the C1MultiPage Tasks menu and then select MultiPage Designer.

      The C1MultiPage Designer Form appears.

2.   Use the Add Child Item button  to add two pages to your C1MultiPage.

3.   Click OK to close the C1MultiPage Designer Form.

4.   In the Solution Explorer window, right-click on the project and select View Code to enter the code editor.

5.   Create a Button control and add text to it by entering the following code to the Page_Load event:

      Visual Basic

Dim nuButton As Button =  New Button()

nuButton.Text = "Hello World!"

      C#

Button nuButton = new Button();

nuButton.Text = "Button";

6.   Create a TextBox control:

      Visual Basic

Dim nuTextBox As TextBox = New TextBox()

      C#

TextBox nuTextBox = new TextBox();

7.   Add the Button control to the first page:

      Visual Basic

C1PageView1.Controls.Add(nuButton)

      C#

C1PageView1.Controls.Add(nuButton);

8.   Add the TextBox control to the second page:

      Visual Basic

C1PageView2.Controls.Add(nuTextBox)

      C#

C1PageView2.Controls.Add(nuTextBox);

9.   Run the program.

This Topic Illustrates the Following:

After you run the project, use the navigation buttons (see Using the Toolbar for Navigation) to switch between the first and second pages. Observe that a Button control appears on the first page, whereas a TextBox control appears on the second page.

 


Send comments about this topic to ComponentOne.
Copyright 1987-2010 ComponentOne LLC. All rights reserved.