In this topic, you will learn how to add a C1SwitchButton control to the content area of a C1ViewPort control in Design view, Source view, and in code. This topic assumes that you have created an AJAX-enabled ASP.NET project that contains a ScriptManager control (see Creating an AJAX-Enabled ASP.NET Project).
In Design View
Complete the following steps:
1. In the Toolbox, double-click C1ViewPortto add a C1ViewPort control to your project.
2. Place your cursor in the content area of the C1ViewPort control.
3. Return to the Toolbox and double-click C1SwitchButton.
A C1SwitchButton control appears in the content area of the C1ViewPort control.
In Source View
Complete the following steps:
1. In the Toolbox, double-click C1ViewPort to add a C1ViewPort control to your project.
2. Click the Source button to enter Source view.
3. Register the C1SwitchButton assembly by entering the following code to the Source page. Place this code beneath the registry for the C1ViewPort assembly.
<%@ Register Assembly="C1.Web.iPhone.3" Namespace="C1.Web.iPhone.C1SwitchButtons" TagPrefix="cc2" %>
4. Enter the following markup between the <cc1:C1ViewPort> and </cc1:C1ViewPort> tags:
<Content>
<cc2:C1SwitchButton On="True" runat="server"/>
</Content>
5. Return to Source view and observe that the C1SwitchButton control appears in the content area of the C1ViewPort control.
In Code
Complete the following steps:
1. In the Toolbox, double-click C1ViewPort to add a C1ViewPort control to your project.
2. In Design view, double-click the page to enter the code editor.
3. Import the following namespaces into your project:
Imports C1.Web.iPhone.C1ViewPort
Imports C1.Web.iPhone.C1SwitchButton
•C#
using C1.Web.iPhone.C1ViewPort;
using C1.Web.iPhone.C1SwitchButton;
4. Create the C1SwitchButton control and customize it by adding the following code to the Page_Load event:
Dim NewSwitchButton As New C1SwitchButton()
NewSwitchButton.On = False
•C#
C1SwitchButton NewSwitchButton = new C1SwitchButton();
NewSwitchButton.On = false;
5. Add the C1SwitchButton control to the C1ViewPort control by adding the following code to the Page_Load event:
C1ViewPort1.ContentPanel.Controls.Add(NewSwitchButton)
•C#
C1ViewPort1.ContentPanel.Controls.Add(NewSwitchButton);
6. Save the project and open it in a Studio for iPhone-compatible browser to execute the program. Observe that the C1SwitchButton control appears in the content area of the C1ViewPort control.
This Topic
Illustrates the Following:
The following image shows a C1SwitchButton control in the content area of the C1ViewPort control: