ComponentOne WebMenus and WebBars for ASP.NET: WebMenus and WebBars for ASP.NET Task-Based Help > C1WebTopicBar Tasks > Creating a C1WebTopicBar Programmatically

Creating a C1WebTopicBar Programmatically

To create a C1WebTopicBarGroup and C1WebTopicBarItem programmatically, complete the following steps:

1.   Add a PlaceHolder control to the Web page.

2.   Add the following Import or Using directives for the C1.Web.Command namespace to your source code.

      Visual Basic

Imports C1.Web.Command

      C#

using C1.Web.Command;

3.   To programmatically create a C1WebTopicBarGroup, complete the following:

      Visual Basic

'First create an instance of the class

Dim topicbar As New C1WebTopicBar()

'Add the topicbar to the placeholder control

PlaceHolder1.Controls.Add(topicbar)

'create the C1WebTopicBarGroup

topicbar.Groups.Add(New C1WebTopicBarGroup("Group 1"))

      C#

//First create an instance of the class

C1WebTopicBar topicbar = new C1WebTopicBar();

//Add the topicbar to the placeholder control

PlaceHolder1.Controls.Add(topicbar);

//Create the C1WebTopicBarGroup

topicbar.Groups.Add(new C1WebTopicBarGroup("Group 1"));

4.   To programmatically create a C1WebTopicBarItem, complete the following:

      Visual Basic

' Create the C1WebTopicBarItem

topicbar.Groups(0).Items.Add(New C1WebTopicBarItem("Item 1", "http://www.google.com"))

      C#

//Create the C1WebTopicBarItem

topicbar.Groups[0].Items.Add(new C1WebTopicBarItem("Item 1", @"http://www.google.com"));


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