Mans_A
November 12, 2024, 3:49pm
1
I am trying to display a readonly property on a page.
I have this code on the page:
<RadzenTextBox @bind-Value="@myObject.ReadonlyProperty" ReadOnly = "true" Style="display: block; width: 100%; height:200px" />
But I am getting the following error:
Property r indexer "ReadonlyProperty" can not be assigned to -- it is read-only
I also tried a RadzenLabel and got the same error.
How can I show read-only properties on a Blazor page?
Please note that the property is read-only and I want to show it and not change it.
enchev
November 12, 2024, 4:04pm
2
Mans_A:
@bind-Value
This is a two-way binding - it can be used only for properties with setters.
Mans_A
November 12, 2024, 4:17pm
3
So what is your advice in these situations? can I use any other component from Radzen to do this job?
enchev
November 12, 2024, 4:19pm
4
The error is related to the framework itself and not related to our components. You can use two-way binding only with read/write properties otherwise you need simple one-way binding: Value="@myObject.ReadonlyProperty"
Mans_A
November 12, 2024, 4:33pm
5
Thanks, I am going to use Value for binding instead of bind-value.
1 Like