# 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](https://docs.wisej.com/api/wisej.web/general/control#onwebrender) and call [RegisterWebMethods](https://docs.wisej.com/api/wisej.web/general/control#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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) WebMethodAttribute()

Initializes the [WebMethodAttribute](https://docs.wisej.com/api/wisej.core/general/wisej.core.webmethodattribute) attribute.

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) WebMethodAttribute(inheritable)

Initializes the [WebMethodAttribute](https://docs.wisej.com/api/wisej.core/general/wisej.core.webmethodattribute) 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

### ![](https://1075938901-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2HvlWXJQMV7DxhGzw7Y1%2Fuploads%2Fgit-blob-2389c55cd19719a73a5ae98e1528c8dc8525cc35%2Finstance.png?alt=media) Inheritable

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