Hello,
I'm trying to practice with MudBlazor doing the same I did before without it (but more complex this time, I added the KeyDown event), and it seems something related to the MudTextField is wrong, because it is not shown in the page (the MudButton is) and at the bottom of the screen it says "there is an unhandled error". I asked here before about the Key event C# method parameters and how to declare it inside the MudTextField tag, but nobody replied; then I continued searching and found something like what you can see in my code, but I'm not sure it is correct (it seems it's not, and/or something else is not).
If you don't ignore my question this time and can guide me to solve this issue, I would apprecite it very much. Thanks.
Pablo
I'm trying to practice with MudBlazor doing the same I did before without it (but more complex this time, I added the KeyDown event), and it seems something related to the MudTextField is wrong, because it is not shown in the page (the MudButton is) and at the bottom of the screen it says "there is an unhandled error". I asked here before about the Key event C# method parameters and how to declare it inside the MudTextField tag, but nobody replied; then I continued searching and found something like what you can see in my code, but I'm not sure it is correct (it seems it's not, and/or something else is not).
HTML:
@page "/calc"
<PageTitle>Calculator</PageTitle>
<h3>Calculator</h3>
<br />
<MudTextField @bind-Value="input" Variant="Variant.Text" @OnKeyDown="OnKeyDown" KeyDownPreventDefault="true"></MudTextField>
<br />
<MudButton Variant="Variant.Filled" @onclick="Calculate">=</MudButton>
@code {
private string input = string.Empty;
private void OnKeyDown(KeyboardEventArgs e)
{
if (Char.IsDigit(e.Key[0]) || "+-*/".Contains(e.Key[0]))
input += e.Key[0];
}
private void Calculate()
{
}
}
If you don't ignore my question this time and can guide me to solve this issue, I would apprecite it very much. Thanks.
Pablo