Im creating a scanner app and I want to clear the input field every time I scan the qr /barcode
I used enter key in c# to achieve this so I assume its key press
I want scan as many QR code and count them and also save them in the indexed db because its PWA app
private async void AddLaybyCode(KeyboardEventArgs keyEvent)
{
if (keyEvent.Key == "Enter")
{
if (CurrentLayby.LaybyCode.Length > 0)
{
//if (CurrentLayby.LaybyCode.Length == 14 || CurrentLayby.LaybyCode.Length == 17)
//{
LaybyCount++;
LaybyCountValue = LaybyCount.ToString();
InputCodeValue = CurrentLayby.LaybyCode;
store = StoreNumber;
await AddRecord();
CurrentLayby.LaybyCode = string.Empty;
}
}
}
This is how i achieved it in blazor
}
apexgeek
Try this:
Create a JavaScript file in your
wwwroot/js
folder, namedindexedDBOperations.js
, with functions to handle IndexedDB operations. Here's a simplified example of such a function for adding records:C# Method to Call JavaScript for IndexedDB Operation
Then, call this JavaScript function from your Blazor component method
SaveCodeToIndexedDB
:apexgeek
Remove the space between @ and code in the beginning.