Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

I need to select the adding radio button by default in my blazor app`

$
0
0

I cannot set the Adding radio button to be selected by default when the page loadsThe actual radio button is not getting selected, but the mode is set to scanning and the UI is green to indicate that the mode is set

My requirement is that the actual button needs to be selected when initialized

This is my card that includes the radio button

<div style="position:sticky"><ParrotInformationExpander ButtonText="Scanner Information"><div style="max-height:250px; overflow-y:auto;"><ol><li>Start scanning barcodes.</li><li>Ensure all items related to the order are scanned off the vehicle.</li> <li>Click on a card to view parcels scanned and not scanned.</li>  <li>Once all items are scanned off the vehicle, the complete button will be activated.</li> </ol></div></ParrotInformationExpander><div class="mb-3"><label for="barcodeInput" class="form-label">Barcode:</label><input type="text" class="form-control" @onkeyup="OnKeyUpAsync" @bind-value="VM.BarcodeInput" @bind-value:event="oninput" @ref="_textboxRef" placeholder="Scan or enter a barcode." /></div><div class="p-card-header"><ParrotRadioGroup GroupName="AddAndRemoveBtns" class="d-flex justify-content-center"><div class="form-check d-inline-block m-3"><ParrotRadioInput @bind-Value="VM.IsAdding" @onclick="@(e => ChangeScanMode(ScanningMode.Adding))" Id="btnradio1" Class="form-check-input" autocomplete="off"><label class="btn btn-outline-success w-100" for="btnradio1">Add</label></ParrotRadioInput></div><div class="form-check d-inline-block m-3"><ParrotRadioInput @bind-Value="VM.IsRemoving" @onclick="@(e => ChangeScanMode(ScanningMode.Removing))" Id="btnradio2" Class="form-check-input" autocomplete="off"><label class="btn btn-outline-danger w-100" for="btnradio2">Remove</label></ParrotRadioInput></div></ParrotRadioGroup><div class="row m-2 "><div class="col-12 mb-1 p-1"><ParrotActionButton Class="btn p-btn-success w-100" Id="CompleteScanOff" IsDisabled="@VM.CompleteBtnDisabled">Complete</ParrotActionButton></div></div></div></div> 

Here is how I am trying to change it from my razor.cs file

 protected override async Task OnInitializedAsync() {     await base.OnInitializedAsync();     VM.FocusOnTextbox = true;     VM.CurrentScanningMode = ScanningMode.Adding;      _inputTimer = new EventTimer(2000) { AutoReset = false };     _inputTimer.Elapsed += OnInputTimerElapsed;     VM.BusyStateHasChanged += StateHasChanged;     VM.OnResultRaised += ShowNotification;     VM.Setup(); } #endregion Protected Methods #region Private Methods /// <summary> /// Changes the scanning mode. /// </summary> private void ChangeScanMode(ScanningMode mode) {     if (mode == ScanningMode.Adding)     {         VM.IsAdding = true;         VM.IsRemoving = false;     }     else     {         VM.IsRemoving = true;         VM.IsAdding = false;     }     VM.CurrentScanningMode = mode;     StateHasChanged(); } 

here is the setup method

 public void Setup(){    try    {        SetAsBusy("Loading");        IsAdding = true;        IsRemoving = false;        SelectedReason = new RedeliveryReasonModel();        if (Reasons.IsNullOrEmpty())        {            GetRedeliveryReasonAsync();        }    }    catch (Exception ex)    {        var sr = new SuccessResultBuilder();        sr = sr.Invalid().WithError(ex);        EmitResult(sr);        return;    }    finally    {        SetAsIdle();    }} 

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>