> For the complete documentation index, see [llms.txt](https://docs.wisej.com/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wisej.com/api/v3.0/wisej.web/extenders/javascript.md).

# JavaScript

Namespace: **Wisej.Web**

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

* [Component](/api/v3.0/wisej.base/general/wisej.base.component.md)
  * [Component](/api/v3.0/wisej.web/general/wisej.web.component.md)
    * [JavaScript](/api/v3.0/wisej.web/extenders/javascript.md)

Allows controls to execute javascript code.

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

```csharp
public class JavaScript : Component, IExtenderProvider
```

{% endtab %}

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

```visual-basic
Public Class JavaScript
    Inherits Component
    Implements IExtenderProvider
```

{% endtab %}
{% endtabs %}

## Constructors

### ![](/files/uCY6T77rh488FWHzpJ6P)JavaScript()

Initializes a new instance of the [JavaScript](/api/v3.0/wisej.web/extenders/javascript.md) without a specified container.

### ![](/files/uCY6T77rh488FWHzpJ6P)JavaScript(container)

Initializes a new instance of the [JavaScript](/api/v3.0/wisej.web/extenders/javascript.md) class with a specified container.

| Name          | Type                                                                                       | Description                                                                                                                                                                                            |
| ------------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **container** | [IContainer](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.icontainer) | An [IContainer](https://docs.microsoft.com/en-us/dotnet/api/system.componentmodel.icontainer) that represents the container of the [JavaScript](/api/v3.0/wisej.web/extenders/javascript.md) extender. |

## Properties

### ![](/files/uCY6T77rh488FWHzpJ6P)Tag

[Object](https://docs.microsoft.com/en-us/dotnet/api/system.object): Returns or sets the object that contains programmer-supplied data associated with the [JavaScript](/api/v3.0/wisej.web/extenders/javascript.md) extender.

## Methods

### ![](/files/uCY6T77rh488FWHzpJ6P)CanExtend(target)

Returns true if the JavaScript extender can offer an extender property to the specified target component.

| Parameter  | Type                                                                | Description                                       |
| ---------- | ------------------------------------------------------------------- | ------------------------------------------------- |
| **target** | [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) | The target object to add an extender property to. |

**Returns:** [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean). true if the [JavaScript](/api/v3.0/wisej.web/extenders/javascript.md) class can offer one or more extender properties; otherwise, false.

### ![](/files/uCY6T77rh488FWHzpJ6P)Clear()

Removes all scripts.

### ![](/files/uCY6T77rh488FWHzpJ6P)GetJavaScript(control)

Retrieves the JavaScript code associated with the specified control. The JavaScript code will be execute on the client when the control is created or refreshed.

| Parameter   | Type                                              | Description                                                                                      |
| ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| **control** | [Control](/api/v3.0/wisej.web/general/control.md) | The [Control](/api/v3.0/wisej.web/general/control.md) for which to retrieve the JavaScript code. |

**Returns:** [String](https://docs.microsoft.com/en-us/dotnet/api/system.string). A [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) containing the javascript code for the specified control.

### ![](/files/uCY6T77rh488FWHzpJ6P)GetJavaScriptEvents(control)

Returns the collection of JavaScript event handlers associated with the control.

| Parameter   | Type                                              | Description                                                                                       |
| ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| **control** | [Control](/api/v3.0/wisej.web/general/control.md) | The [Control](/api/v3.0/wisej.web/general/control.md) to attach the JavaScript event handlers to. |

**Returns:** [ClientEventCollection](/api/v3.0/wisej.web/general/control/wisej.web.javascript.clienteventcollection.md).

### ![](/files/uCY6T77rh488FWHzpJ6P)GetJavaScriptSource(control)

Retrieves the JavaScript file associated with the specified control. The JavaScript code will be execute on the client when the control is created or refreshed.

| Parameter   | Type                                              | Description                                                                                      |
| ----------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| **control** | [Control](/api/v3.0/wisej.web/general/control.md) | The [Control](/api/v3.0/wisej.web/general/control.md) for which to retrieve the JavaScript file. |

**Returns:** [String](https://docs.microsoft.com/en-us/dotnet/api/system.string). A [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) containing the name of the javascript file for the specified control.

### ![](/files/uCY6T77rh488FWHzpJ6P)SetJavaScript(control, script)

Associates JavaScript code with the specified control.

| Parameter   | Type                                                                | Description                                                                             |
| ----------- | ------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| **control** | [Control](/api/v3.0/wisej.web/general/control.md)                   | The [Control](/api/v3.0/wisej.web/general/control.md) to associate the JavaScript with. |
| **script**  | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The JavaScript code to execute when the control is created.                             |

### ![](/files/uCY6T77rh488FWHzpJ6P)SetJavaScriptSource(control, file)

Associates JavaScript file with the specified control.

| Parameter   | Type                                                                | Description                                                                                  |
| ----------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| **control** | [Control](/api/v3.0/wisej.web/general/control.md)                   | The [Control](/api/v3.0/wisej.web/general/control.md) to associate the JavaScript file with. |
| **file**    | [String](https://docs.microsoft.com/en-us/dotnet/api/system.string) | The JavaScript file to execute when the control is created.                                  |

## Implements

| Name                                                                                   | Description                                    |
| -------------------------------------------------------------------------------------- | ---------------------------------------------- |
| [IWisejComponent](/api/v3.0/wisej.core/interfaces/wisej.core.iwisejcomponent.md)       | All wisej components implement this interface. |
| [IWisejSerializable](/api/v3.0/wisej.core/interfaces/wisej.core.iwisejserializable.md) | Allows an object to serialize itself.          |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.wisej.com/api/v3.0/wisej.web/extenders/javascript.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
