<div class="meta" robots="noindex">

</div>

Class

# WebToolbarContainer

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2020r2. There is no replacement.

</div>

## Description

A container control in a `WebToolbar</api/user_interface/web/webtoolbar>`.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                       | Type                                                 | Read-Only | Shared |
|--------------------------------------------|------------------------------------------------------|-----------|--------|
| `Badge<webtoolbarcontainer.badge>`         | `String</api/data_types/string>`                     |           |        |
| `Caption<webtoolbarcontainer.caption>`     | `String</api/data_types/string>`                     |           |        |
| `Caption<webtoolbarcontainer.caption>`     | `String</api/data_types/string>`                     |           |        |
| `Container<webtoolbarcontainer.container>` | `WebContainer</api/user_interface/web/webcontainer>` |           |        |
| `Enabled<webtoolbarcontainer.enabled>`     | `Boolean</api/data_types/boolean>`                   |           |        |
| `Icon<webtoolbarcontainer.icon>`           | `WebPicture</api/graphics/webpicture>`               |           |        |
| `Size<webtoolbarcontainer.size>`           | `Integer</api/data_types/integer>`                   |           |        |
| `Tag<webtoolbarcontainer.tag>`             | `Variant</api/data_types/variant>`                   |           |        |
| `Tooltip<webtoolbarcontainer.tooltip>`     | `String</api/data_types/string>`                     |           |        |
| `Visible<webtoolbarcontainer.visible>`     | `Boolean</api/data_types/boolean>`                   |           |        |

## Property descriptions

<div id="webtoolbarcontainer.badge">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Badge

**Badge** As `String</api/data_types/string>`

A small graphical element used to displayed additional information alongside the `WebToolbarItem</api/user_interface/web/webtoolbaritem>`.

The text appears in white on a round rectangle with a red background.

<div id="webtoolbarcontainer.caption">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Caption

**Caption** As `String</api/data_types/string>`

The caption that appears in the control.

The Caption can be surrounded by "\<raw\>\</raw\>" tags to temporarily disable HTML parsing. For example, you could bold just a single word in a Caption by doing this:

``` xojo
item.Caption = "<raw><b>bold</b></raw> text"
```

This code changes the caption for an existing container on the toolbar:

``` xojo
Var item As WebToolbarContainer
item = WebToolbarContainer(Toolbar1.ItemWithName("SearchControl"))

If item <> Nil Then
  item.Caption = "New Caption"
End If
```

<div id="webtoolbarcontainer.container">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Container

**Container** As `WebContainer</api/user_interface/web/webcontainer>`

The ContainerControl that is assigned to the <span class="title-ref">WebToolbarContainer</span>. You can specify the container in the IDE at design time or in code.

This code changes the ContainerControl used by an existing container on the toolbar:

``` xojo
Var item As WebToolbarContainer
item = WebToolbarContainer(Toolbar1.ItemWithName("SearchControl"))

If item <> Nil Then
  item.Container = New ContainerControl1
End If
```

<div id="webtoolbarcontainer.enabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Enabled

**Enabled** As `Boolean</api/data_types/boolean>`

If `True</api/language/true>`, the item can be pressed. If `False</api/language/false>`, it cannot be.

<div id="webtoolbarcontainer.icon">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Icon

**Icon** As `WebPicture</api/graphics/webpicture>`

The `picture</api/graphics/webpicture>` that is associated with the `WebToolbarItem</api/user_interface/web/webtoolbaritem>`.

<div id="webtoolbarcontainer.size">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Size

**Size** As `Integer</api/data_types/integer>`

For vertical toolbars, Size is the height of the item. For horizontal toolbars, Size is the width of the item. The opposing dimension will always be dictated by the toolbar. For example, a horizontal toolbar which is 56 pixels tall, a container with a size of 200 inside it would have the dimensions 200 x 56.

This code changes the size for an existing container on the toolbar:

``` xojo
Var item As WebToolbarContainer
item = WebToolbarContainer(Toolbar1.ItemWithName("SearchControl"))

If item <> Nil Then
  item.Size = 200
End If
```

<div id="webtoolbarcontainer.tag">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Tag

**Tag** As `Variant</api/data_types/variant>`

A hidden value associated with the `WebToolbarItem</api/user_interface/web/webtoolbaritem>`.

Since this is a `Variant</api/data_types/variant>`, this can be used to associate any type of data, even an object, with the `WebToolbarItem</api/user_interface/web/webtoolbaritem>`.

<div id="webtoolbarcontainer.tooltip">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Tooltip

**Tooltip** As `String</api/data_types/string>`

A helpful message that describes the purpose of the `WebToolbarItem</api/user_interface/web/webtoolbaritem>`.

<div id="webtoolbarcontainer.visible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

WebToolbarContainer.Visible

**Visible** As `Boolean</api/data_types/boolean>`

Indicates whether or not the WebToolbarItem is visible.

This property is useful when you need to hide/show WebToolbarItem's dynamically at runtime.

## Notes

An important feature of the <span class="title-ref">WebToolbarContainer</span> is that it enables you to add controls other than buttons and menus to a `WebToolbar</api/user_interface/web/webtoolbar>`. Create the container control and add it to the project; then assign it to the Container property of the <span class="title-ref">WebToolbarContainer</span>. The container will be resized to the dimensions of the item. When designing the container, be sure to set all lock properties appropriately.

In order for the container to access the page the toolbar is on, the container must have a property of type `WebPage</api/user_interface/web/webpage>`. It can be the actual page, for example WebPage1, or it can be just WebPage. However, if you use WebPage, you will need to typecast in order to get to the actual page. To set up the property, in the Open event of the Toolbar, you will need to cast the toolbar's container control as your original container control. See the example below.

## Sample code

To add a search field to a toolbar, you first create a SearchFieldContainer by adding a WebSearchField to a ContainerControl.

On WebPage1, add a toolbar and then add a Container item to it (named "SearchControl"). Select it and enter "SearchFieldContainer" in the Target property field. You'll also want to change the Size property to 200.

Now run the app to see the SearchField in the toolbar.

Most of the time, the container will need to access the Web Page that contains it.

You can do this in the Open event handler for the toolbar that is on the web page. This code gets the <span class="title-ref">WebToolbarContainer</span> that is named "SearchField" on the toolbar and casts it to a SearchFieldContainer so that the ParentPage property (added to SearchFieldContainer: ParentPage As WebPage1) can be set to the web page (Self):

``` xojo
' Link the SearchField container control to the web page
Var search As WebToolbarContainer
search = WebToolbarContainer(Me.ItemWithName("SearchControl"))

Var searchField As SearchFieldContainer
searchField = SearchFieldContainer(search.Container)
searchField.ParentPage = Self
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

This can also be written more succinctly like this:

``` xojo
SearchFieldContainer(WebToolbarContainer(Me.ItemWithName("SearchControl")).Container).ParentPage = Self
```

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

With ParentPage property value now specified, you can have code on the SearchFieldContainer that uses it to access methods, properties or controls on the web page. This code in the WebSearchField.TextChanged event handler (on the SearchFieldContainer) adds search criteria to a ListBox on the web page when the user presses return/enter in the search field:

``` xojo
If ParentPage Is Nil Then Return ' Ensure that ParentPage was configured before using it

If Me.Text <> "" Then
  ' If the user typed something, then add it to the ListBox on the web page
  ParentPage.RecentSearchesList.InsertRow(0, Me.Text)
End If
```

## Compatibility

Web projects on all supported operating systems.

## See also

`WebToolbarItem</api/user_interface/web/webtoolbaritem>` parent class; `WebMenuItem</api/user_interface/web/webmenuitem>`, `WebToolbar</api/user_interface/web/webtoolbar>`, `WebToolbarButton</api/user_interface/web/webtoolbarbutton>`, `WebToolbarFlexibleSpace</api/deprecated/webtoolbarflexiblespace>`, `WebToolbarItem</api/user_interface/web/webtoolbaritem>`, `WebToolbarMenu</api/deprecated/webtoolbarmenu>`, `WebToolbarSeparator</api/deprecated/webtoolbarseparator>`, `WebToolbarSpace</api/deprecated/webtoolbarspace>` classes.
