# Button

Namespace: **Wisej.Web**

Assembly: **Wisej.Framework** (4.0.0.0)

* [Control](/api/wisej.web/general/control.md)
  * [ButtonBase](/api/wisej.web/buttons/wisej.web.buttonbase.md)
    * [Button](/api/wisej.web/buttons/button.md)

Represents a button control.

{% tabs %}
{% tab title="C#" %}

```csharp
public class Button : ButtonBase, IButtonControl
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class Button
    Inherits ButtonBase
    Implements IButtonControl
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/hsR4ok3152WyAf8J2C1u) Button()

Initializes a new instance of the [Button](/api/wisej.web/buttons/button.md) class.

### ![](/files/hsR4ok3152WyAf8J2C1u) Button(text, onClick)

Initializes a new instance of the [Button](/api/wisej.web/buttons/button.md) class with specific initial settings.

| Name        | Type                                                                                | Description                                                        |
| ----------- | ----------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| **text**    | [String](https://docs.microsoft.com/dotnet/api/system.string)                       | Initial text.                                                      |
| **onClick** | [Action\<Object, EventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | Optional [Click](/api/wisej.web/general/control.md#click) handler. |

### ![](/files/hsR4ok3152WyAf8J2C1u) Button(text, location, size, onClick)

Initializes a new instance of the [Button](/api/wisej.web/buttons/button.md) class with specific initial settings.

| Name         | Type                                                                                | Description             |
| ------------ | ----------------------------------------------------------------------------------- | ----------------------- |
| **text**     | [String](https://docs.microsoft.com/dotnet/api/system.string)                       | Initial text.           |
| **location** | [Point](https://docs.microsoft.com/dotnet/api/system.drawing.point)                 | Initial location.       |
| **size**     | [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size)                   | Initial size.           |
| **onClick**  | [Action\<Object, EventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | Optional click handler. |

### ![](/files/hsR4ok3152WyAf8J2C1u) Button(text, ImageSource, location, size, onClick)

Initializes a new instance of the [Button](/api/wisej.web/buttons/button.md) class with specific initial settings.

| Name            | Type                                                                                | Description             |
| --------------- | ----------------------------------------------------------------------------------- | ----------------------- |
| **text**        | [String](https://docs.microsoft.com/dotnet/api/system.string)                       | Initial text.           |
| **ImageSource** | [String](https://docs.microsoft.com/dotnet/api/system.string)                       | Image source.           |
| **location**    | [Point](https://docs.microsoft.com/dotnet/api/system.drawing.point)                 | Initial location.       |
| **size**        | [Size](https://docs.microsoft.com/dotnet/api/system.drawing.size)                   | Initial size.           |
| **onClick**     | [Action\<Object, EventArgs>](https://docs.microsoft.com/dotnet/api/system.action-2) | Optional click handler. |

## Properties

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoSizeMode

[AutoSizeMode](/api/wisej.web/enumerations/wisej.web.autosizemode.md): Returns or sets the mode by which the [Button](/api/wisej.web/buttons/button.md) automatically resizes itself. (Default: `GrowOnly`)

### ![](/files/hsR4ok3152WyAf8J2C1u) AutoToolTip

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns or sets whether a tooltip is displayed when the text extends beyond the size of the control. (Default: `False`)

The auto tooltip is set on the browser using the [title](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title) attribute managed by the browser, does not use the themed tooltip managed by Wisej.NET.

### ![](/files/hsR4ok3152WyAf8J2C1u) BorderStyle

[BorderStyle](/api/wisej.web/enumerations/wisej.web.borderstyle.md): Returns or sets the border style of the button control. (Default: `Solid`)

### ![](/files/hsR4ok3152WyAf8J2C1u) DialogResult

[DialogResult](/api/wisej.web/enumerations/wisej.web.dialogresult.md): Returns or sets a value that is returned to the parent form when the button is clicked. (Default: `None`)

### ![](/files/hsR4ok3152WyAf8J2C1u) Display

[Display](/api/wisej.web/enumerations/wisej.web.display.md): Returns or sets the [Display](/api/wisej.web/enumerations/wisej.web.display.md) mode of the control to determine whether to display the icon, the text or both. (Default: `Both`)

### ![](/files/hsR4ok3152WyAf8J2C1u) ImageSpacing

[Nullable\<Int32>](https://docs.microsoft.com/dotnet/api/system.nullable-1): Returns or sets the distance in pixels between the image and the label inside the button. (Default: `null`)

### ![](/files/hsR4ok3152WyAf8J2C1u) MenuItems

[MenuItemCollection](/api/wisej.web/menus/wisej.web.menu.menuitemcollection.md): Returns the collection of [MenuItem](/api/wisej.web/menus/wisej.web.menuitem.md) objects associated with the button.

### ![](/files/hsR4ok3152WyAf8J2C1u) Repeat

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Enables or disables the auto-repeat feature. When enabled, the button keeps firing click events at an increasing rate while the user keeps the button pressed. (Default: `False`)

### ![](/files/hsR4ok3152WyAf8J2C1u) Shortcut

[Shortcut](/api/wisej.web/enumerations/wisej.web.shortcut.md): Returns or sets a value indicating the shortcut key associated with the button. (Default: `None`)

## Methods

### ![](/files/lzopMboA31bVq8UIcbT3) Dispose(disposing)

Disposes the control.

| Parameter     | Type                                                            | Description                                                                 |
| ------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------- |
| **disposing** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | true when this method is called by the application rather than a finalizer. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnAddReferences(items)

Adds references components to the list. Referenced components can be added individually or as a reference to a collection.

| Parameter | Type                                                                    | Description                                             |
| --------- | ----------------------------------------------------------------------- | ------------------------------------------------------- |
| **items** | [IList](https://docs.microsoft.com/dotnet/api/system.collections.ilist) | Container for the referenced components or collections. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnBindingContextChanged(e)

Fires the [BindingContextChanged](/api/wisej.web/general/control.md#bindingcontextchanged) event.

| Parameter | Type                                                                | Description                                                                                          |
| --------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | An [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnClick(e)

Fires the Click event.

| Parameter | Type                                                                | Description                                                                                          |
| --------- | ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | An [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnItemClick(e)

Fires the [ItemClicked](#itemclicked) event.

| Parameter | Type                                                                                                        | Description                                                                                                                                 |
| --------- | ----------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| **e**     | [MenuButtonItemClickedEventArgs](/api/wisej.web/buttons/button/wisej.web.menubuttonitemclickedeventargs.md) | A [MenuButtonItemClickedEventArgs](/api/wisej.web/buttons/button/wisej.web.menubuttonitemclickedeventargs.md) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnMenuCollapse(e)

Fires the [MenuCollapse](#menucollapse) event.<mark style="color:blue;background-color:green;">Since 3.5.5</mark>

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnMenuPopup(e)

Fires the [MenuPopup](#menupopup) event.<mark style="color:blue;background-color:green;">Since 3.5.5</mark>

| Parameter | Type                                                                | Description                                                                                         |
| --------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
| **e**     | [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) | A [EventArgs](https://docs.microsoft.com/dotnet/api/system.eventargs) that contains the event data. |

### ![](/files/lzopMboA31bVq8UIcbT3) OnWebRender(config)

Renders the client component.

| Parameter  | Type                                                          | Description                   |
| ---------- | ------------------------------------------------------------- | ----------------------------- |
| **config** | [Object](https://docs.microsoft.com/dotnet/api/system.object) | Dynamic configuration object. |

### ![](/files/hsR4ok3152WyAf8J2C1u) PerformClick()

Generates a [Click](/api/wisej.web/general/control.md#click) event for a button.

## Events

### ![](/files/hsR4ok3152WyAf8J2C1u) ItemClicked

[MenuButtonItemClickedEventHandler](/api/wisej.web/buttons/button/wisej.web.menubuttonitemclickedeventhandler.md) Fired when the user clicks one of the drop down menu items.

### ![](/files/hsR4ok3152WyAf8J2C1u) MenuCollapse

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired when the button menu is closed.<mark style="color:blue;background-color:green;">Since 3.5.5</mark>

### ![](/files/hsR4ok3152WyAf8J2C1u) MenuPopup

[EventHandler](https://docs.microsoft.com/dotnet/api/system.eventhandler) Fired after the button menu is displayed on the client.<mark style="color:blue;background-color:green;">Since 3.5.5</mark>

## Inherited By

| Name                                                           | Description                        |
| -------------------------------------------------------------- | ---------------------------------- |
| [SplitButton](/api/wisej.web/buttons/wisej.web.splitbutton.md) | Represents a split button control. |

## Implements

| Name                                                                              | Description                                                                                                           |
| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| [IUserData](/api/wisej.web/interfaces/wisej.web.iuserdata.md)                     | Provides access to the `UserData` and `Tag` properties associated to the component implementing this interface.       |
| [IBindableComponent](/api/wisej.web/data-binding/wisej.web.ibindablecomponent.md) | Bindable components implement this interface.                                                                         |
| [IButtonControl](/api/wisej.web/interfaces/wisej.web.ibuttoncontrol.md)           | Allows a control to act like a button on a [Form](/api/wisej.web/containers/form.md).                                 |
| [ICommandSource](/api/wisej.web/interfaces/wisej.web.icommandsource.md)           | Defines an object that can invoke a [Command](/api/wisej.web/interfaces/wisej.web.icommandsource.md#command).         |
| [IDropTarget](/api/wisej.web/interfaces/wisej.web.idroptarget.md)                 | Controls that support drag & drop operations implement this interface.                                                |
| [IImage](/api/wisej.web/interfaces/wisej.web.iimage.md)                           | Provides access to common image properties across the controls that implement this interface.                         |
| [IWisejComponent](/api/wisej.core/interfaces/wisej.core.iwisejcomponent.md)       | All wisej components implement this interface.                                                                        |
| [IWisejControl](/api/wisej.core/interfaces/wisej.core.iwisejcontrol.md)           | All wisej controls derived from the [Control](/api/wisej.web/general/control.md) class must implement this interface. |
| [IWisejSerializable](/api/wisej.core/interfaces/wisej.core.iwisejserializable.md) | Allows an object to serialize itself.                                                                                 |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web/buttons/button.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
