how can i get the onInput also to fire the Calculate function ? When using the onChange the result is shown when the input box loses focus.
<h1>Times table</h1>
<p><input @bind-value="TableNumber" @bind-value:event="oninput" @onchange=Calculate size="2" /> Times table</p>
<hr />
<table class="table-borderless">
<thead>
<tr>
<th colspan="3">Times table: @TableNumber</th>
</tr>
</thead>
<tbody>
@foreach (var TableItem in table)
{
<tr>
<td>@TableItem.Multiplier * </td>
<td>@TableItem.TimesTable = </td>
<td>@TableItem.Total</td>
</tr>
}
</tbody>
</table>
@code{
private int TableNumber = 0;
private int Number1;
private IList<TableItem>
table = new List<TableItem>();
private void Calculate()
{
table.Clear();
int i = 0;
while (i < 11)
{
int TotalTmp = TableNumber * i;
table.Add(new TableItem { TimesTable = TableNumber, Multiplier = i, Total = TotalTmp });
i++;
}
Number1 = 10 * TableNumber;
}
// on load
void SomeStartupMethod()
{
// Do Some Work
Calculate();
}
Task SomeStartupTask()
{
// Do some task based work
return Task.CompletedTask;
}
protected override async Task OnInitializedAsync()
{
SomeStartupMethod();
await SomeStartupTask();
}
// end on load
}
using System;
public class TableItem
{
public int TimesTable { get; set; }
public int Multiplier { get; set; }
public int Total { get; set; }
public TableItem()
{
}
}
Member
41 Points
129 Posts
onInpute also fire the calculate function
Jul 17, 2020 12:27 PM|Bradly|LINK
how can i get the onInput also to fire the Calculate function ? When using the onChange the result is shown when the input box loses focus.
Thanks in advance