This seems like a homework assignment.
If I understand, you want to use a radio button to select between calculating an area or perimeter of a square given one side of the square. This is how I would approach the problem.
Enum to populate the radio buttons as illustrated in the official documentation.
https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/binding?view=aspnetcore-8.0#radio-buttons
namespace BlazorStandAloneApp.Models
{
public class ComponentEnums
{
public enum Calulation { Perimeter, Area }
}
}
Blazor Component
@page "/square"
@using System.ComponentModel.DataAnnotations
@using static BlazorStandAloneApp.Models.ComponentEnums
<h3>Square Area or Perimeter</h3>
<PageTitle>Square</PageTitle>
<div>
<fieldset>
<legend>Manufacturer</legend>
<InputRadioGroup @bind-Value="Calulation">
@foreach (var calculationItem in Enum.GetValues<Calulation>())
{
<div>
<label>
<InputRadio Value="calculationItem" />
@calculationItem
</label>
</div>
}
</InputRadioGroup>
</fieldset>
<fieldset>
<legend>Side of a square</legend>
<InputNumber @bind-Value="Side" />
<button @onclick="Calculate">
Calculate
</button>
</fieldset>
<fieldset>
<legend>Result</legend>
<div>@Result</div>
</fieldset>
</div>
@code {
[Required, EnumDataType(typeof(Calulation))]
public Calulation? Calulation { get; set; } = null;
[Required]
public decimal? Side { get; set; } = null;
public decimal? Result { get; set; } = null;
private void Calculate()
{
if (Calulation == Models.ComponentEnums.Calulation.Perimeter)
{
Result = Side * 4;
}
else
{
Result = Side * Side;
}
}
}