@page "/call-js-example-3" @inject IJSRuntime JS

Call JS Example 3

@if (stockSymbol is not null) {

@stockSymbol price: @price.ToString("c")

} @if (result is not null) {

@result

} @code { private Random r = new(); private string? stockSymbol; private decimal price; private string? result; private async Task SetStock() { stockSymbol = $"{(char)('A' + r.Next(0, 26))}{(char)('A' + r.Next(0, 26))}"; price = r.Next(1, 101); var interopResult = await JS.InvokeAsync("displayTickerAlert2", stockSymbol, price); result = $"Result of TickerChanged call for {stockSymbol} at " + $"{price.ToString("c")}: {interopResult}"; } }