# WebMethodAttribute

Namespace: **Wisej.Core**

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

Indicates that the method can be called from the browser using JavaScript.

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

```csharp
public class WebMethodAttribute : Attribute
```

{% endtab %}

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

```visual-basic
Public Class WebMethodAttribute
    Inherits Attribute
```

{% endtab %}
{% endtabs %}

You can add this attribute to static methods in your Wisej application Program class and to instance methods in top level containers: Page, Form, and Desktop.\
If you want to register web methods on child controls, you can, but Wisej only searches top level containers automatically. To register web methods on a child control, extend the control class, override [OnWebRender](/api/wisej.web/general/control.md#onwebrender) and call [RegisterWebMethods](/api/wisej.web/general/control.md#registerwebmethods).

```csharp

public class MyButton : Button
{
  protected override void OnWebRender(dynamic config)
  {
    base.OnWebRender((object)config);
    RegisterWebMethods(config);
  }
}

```

Default parameters are not supported in Web Methods. This is supported:

```csharp

[WebMethod]
public void myWebMethod(string s)

```

But this is not supported:

```csharp

[WebMethod]
public void myWebMethod(string s = "default value")

```

## Constructors

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

Initializes the [WebMethodAttribute](/api/wisej.core/general/wisej.core.webmethodattribute.md) attribute.

### ![](/files/hsR4ok3152WyAf8J2C1u) WebMethodAttribute(inheritable)

Initializes the [WebMethodAttribute](/api/wisej.core/general/wisej.core.webmethodattribute.md) attribute.

| Name            | Type                                                            | Description                                                       |
| --------------- | --------------------------------------------------------------- | ----------------------------------------------------------------- |
| **inheritable** | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean) | Indicates whether the web method is inherited by derived classes. |

## Properties

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

[Boolean](https://docs.microsoft.com/dotnet/api/system.boolean): Returns a value indicating whether the web method is inherited by derived classes.


---

# 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.core/general/wisej.core.webmethodattribute.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.
