I am fresh into coding and working on an UI in Mudblazor. What I am trying to do is I have a mudradio selection Yes/No, when user selects "No", it should display some text fields which I am good with, but when the user selects "Yes", it should open a modal and that is what I am failing to accomplish.
Here is my code:
<MudDialog><DialogContent><MudGrid><MudItem xs="12"/><MudItem xs="12" sm="6"><MudText>Do you want to use the same account?</MudText></MudItem><MudItem xs="12" sm="6"><MudRadioGroup @bind-Value="SameAccount" SelectedOptionChanged="OnSelectedOptionChangedHandler"><MudRadio Value="@("Yes")" >Yes</MudRadio><MudRadio Value="@("No")">No</MudRadio></MudRadioGroup></MudItem> @if (SameAccount == "No") {<MudItem xs="12" /><MudItem xs="3"><MudTextField @bind-Value="_FirstName" Margin="Margin.Dense" Label="First Name" Variant="Variant.Outlined" Required="true" RequiredError="First Name is required."></MudTextField></MudItem><MudItem xs="3"><MudTextField class="ml-3" @bind-Value="_LastName" Margin="Margin.Dense" Label="Last Name" Variant="Variant.Outlined" Required="true" RequiredError="Last Name is required."></MudTextField></MudItem> }</MudGrid></DialogContent></MudDialog>In the @code or C# part, I am trying to bring the condition of SameAccount = yes and to pop up my modal AccountInput:
@code { public string SameAccount { get; set; } = ""; public string _FirstName { get; set; } = ""; public string _LastName { get; set; } = "";[CascadingParameter]private IMudDialogInstance MudDialog { get; set; }[Inject] private IDialogService DialogService { get; set; }private async Task OnSelectedOptionChangedHandler(){ if (SameAccount == "Yes") { var options = new DialogOptions { CloseButton = false, FullWidth = true, MaxWidth = MaxWidth.Medium, BackdropClick = false }; var parameters = new DialogParameters<Modals.AccountInput> { }; var dialog = await DialogService.ShowAsync<Modals.AccountInput>("Account Input", parameters, options); var result = await dialog.Result; } } }Unfortunately, when I select "Yes", the code doesn't open the modal.
Can you please kindly assist me and advise me and explain what I am doing wrong?
Thank you