Blazor, event listener as inline delegate or handler in @functions section

blazor events listener

Question

I got different reaction (output in console) when using inline delegate or when implementing a handler in @functions section. I don't understand why! Is that a bug or something is missing me?

<input type="text" onkeyup="@(e => Console.Write(e.Key))" />

It gives me immediate output in console. But when I use a handler like this, I got nothing:

<input type="text" onkeyup="@showKey"/>
@functions{
    void showKey(UIKeyboardEventArgs e){
        Console.Write(e.Key);
    }
}

Accepted Answer

Both don't work for me with your code. But do work when I change them to Console.WriteLine(e.key)

I guess Console.Write is not supported because browsers don't support this, Console.Writeline translates to console.log and Console.Write has nothing to translate to.



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow