# IReadOnlyExtensions

Namespace: **Wisej.Web.Markup**

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

Adds [fluent markup](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/markup/markup) extension methods to the [IReadOnly](/api/wisej.web/interfaces/wisej.web.ireadonly.md) implementation.

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

```csharp
public class IReadOnlyExtensions
```

{% endtab %}

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

```visual-basic
Public Class IReadOnlyExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/lIX317sDtMTZJBi9oSIx) OnReadOnlyChanged\<TReadOnly>(target, action)

Attaches an action to be executed when the [ReadOnlyChanged](/api/wisej.web/interfaces/wisej.web.ireadonly.md#readonlychanged) event is raised.

| Parameter     | Type                                                                                  | Description                                                                                                                           |
| ------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| **TReadOnly** |                                                                                       | The type that implements [IReadOnly](/api/wisej.web/interfaces/wisej.web.ireadonly.md).                                               |
| **target**    | [TReadOnly](/api/wisej.web.markup/extensions/wisej.web.markup.ireadonlyextensions.md) | The target object whose [ReadOnlyChanged](/api/wisej.web/interfaces/wisej.web.ireadonly.md#readonlychanged) event is being monitored. |
| **action**    | [Action\<TReadOnly>](https://docs.microsoft.com/dotnet/api/system.action-1)           | The action to execute when the [ReadOnlyChanged](/api/wisej.web/interfaces/wisej.web.ireadonly.md#readonlychanged) event occurs.      |

**Returns:** [TReadOnly](/api/wisej.web.markup/extensions/wisej.web.markup.ireadonlyextensions.md). The target object, allowing for method chaining.

This extension method allows you to easily attach an action to the [ReadOnlyChanged](/api/wisej.web/interfaces/wisej.web.ireadonly.md#readonlychanged) event of an object.

```csharp

myReadOnlyObject.OnReadOnlyChanged(obj => AlertBox.Show("ReadOnly state changed."));

```

### ![](/files/lIX317sDtMTZJBi9oSIx) ReadOnly\<TReadOnly>(target, value)

Sets the read-only status of the specified target object.

| Parameter     | Type                                                                                  | Description                                                                                                        |
| ------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| **TReadOnly** |                                                                                       | The type of the target object, which must implement [IReadOnly](/api/wisej.web/interfaces/wisej.web.ireadonly.md). |
| **target**    | [TReadOnly](/api/wisej.web.markup/extensions/wisej.web.markup.ireadonlyextensions.md) | The target object whose read-only status is to be set.                                                             |
| **value**     | [Boolean](https://docs.microsoft.com/dotnet/api/system.boolean)                       | A boolean value indicating the desired read-only status.                                                           |

**Returns:** [TReadOnly](/api/wisej.web.markup/extensions/wisej.web.markup.ireadonlyextensions.md). The target object with the updated read-only status.

This extension method allows you to set the read-only status of an object that implements the [IReadOnly](/api/wisej.web/interfaces/wisej.web.ireadonly.md) interface.

```csharp

var myObject = new MyReadOnlyObject();
myObject.ReadOnly(false);

```


---

# 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.markup/extensions/wisej.web.markup.ireadonlyextensions.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.
