Hi,
I've a class model as below
public partial class Developer
{
public int Id { get; set; }
public int _currentYear = DateTime.Today.Year;
public string EnvT { get { return _currentYear.ToString(); } }
}
I want to retrieve EnvT in TextBox as below
<EditForm Model="@dev" OnValidSubmit="@OnValidSubmit">
<DataAnnotationsValidator />
<RadzenTextBox style="width: 100%;" Name="Numéro EnvT" @bind-Value=@dev.EnvT Disabled=true/>
<ValidationMessage For="@(() => dev.EnvT)" />
</EditForm>
Edit razor page is
<FormEdit ButtonText="Update" dev="dev"
OnValidSubmit="@EditDeveloper" />
@code {
[Parameter] public int developerId { get; set; }
Developer dev = new Developer();
protected async override Task OnParametersSetAsync()
{
dev = await http.GetFromJsonAsync<Developer>($"api/developer/{developerId}");
}
async Task EditDeveloper()
{
await http.PutAsJsonAsync("api/developer", dev);
await js.InvokeVoidAsync("alert", $"Updated Successfully!");
uriHelper.NavigateTo("developer");
}
I've a message error : Property or indexer 'property' cannot be assigned to -- it is read only
I don't how why I've this error.
Do I have to do this to find the EnvT value in the database table?
Thanks in advance!