I am trying to catch table input and changes in a Blazor Wasm table developed with VS Community 2019. I am able to catch onkeydown (which is only giving me the key info with nothing on where in the table it was pressed), but I can't seem to catch oninput or onchange. The documentation here doesn't help much. Am I missing something? Do I need to do this via JavaScript?
Update: Not sure how I missed this other than the fact that there is no error indication in the browser window, but after the OnKeyDown handler writes to the console, the exception shown below my code is logged in the console.
Here's my table data Blazor markup and event handlers:
<td contenteditable="true"
@onchange="Cell_OnChange"
@oninput="Cell_OnInput"
@onkeydown="Cell_OnKeyDown">
@TableValue
</td>
private void Cell_OnChange(ChangeEventArgs e)
{
Console.WriteLine("OnChange");
}
private void Cell_OnInput(ChangeEventArgs e)
{
Console.WriteLine("OnInput");
}
private void Cell_OnKeyDown(KeyboardEventArgs e)
{
Console.WriteLine("OnKeyDown");
}
Exception shown in console:
blazor.webassembly.js:1 Uncaught (in promise) Error:
System.InvalidOperationException: There was an error parsing the event arguments. EventId: '1500'. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.AspNetCore.Components.Web.WebEventData.DeserializeChangeEventArgs (System.String eventArgsJson) <0x3626798 + 0x0001e> in <filename unknown>:0
at Microsoft.AspNetCore.Components.Web.WebEventData.ParseEventArgsJson (System.UInt64 eventHandlerId, System.String eventArgsType, System.String eventArgsJson) <0x33bc230 + 0x00206> in <filename unknown>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x2868918 + 0x000ce> in <filename unknown>:0
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.InvokeSynchronously (Microsoft.JSInterop.JSRuntime jsRuntime, Microsoft.JSInterop.Infrastructure.DotNetInvocationInfo& callInfo, Microsoft.JSInterop.Infrastructure.IDotNetObjectReference objectReference, System.String argsJson) <0x3c67378 + 0x0017a> in <filename unknown>:0
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet (Microsoft.JSInterop.JSRuntime jsRuntime, Microsoft.JSInterop.Infrastructure.DotNetInvocationInfo invocationInfo, System.String argsJson) <0x3c66d20 + 0x0009e> in <filename unknown>:0
at Object.endInvokeDotNetFromJS (https://localhost:44307/_framework/blazor.webassembly.js:1:10049)
at Object.invokeJSFromDotNet (https://localhost:44307/_framework/blazor.webassembly.js:1:9669)
at _mono_wasm_invoke_js_marshalled (https://localhost:44307/_framework/wasm/dotnet.3.2.0.js:1:171433)
at do_icall (<anonymous>:wasm-function[6049]:0x10f8b1)
at do_icall_wrapper (<anonymous>:wasm-function[1896]:0x50b6a)
at interp_exec_method (<anonymous>:wasm-function[1120]:0x2588e)
at interp_runtime_invoke (<anonymous>:wasm-function[5655]:0xf7391)
at mono_jit_runtime_invoke (<anonymous>:wasm-function[5109]:0xddb3d)
at do_runtime_invoke (<anonymous>:wasm-function[1410]:0x3ba85)
at mono_runtime_try_invoke (<anonymous>:wasm-function[418]:0xcfdb)
endInvokeDotNetFromJS @ blazor.webassembly.js:1
invokeJSFromDotNet @ blazor.webassembly.js:1
_mono_wasm_invoke_js_marshalled @ dotnet.3.2.0.js:1
do_icall @ 00755c3a:1
do_icall_wrapper @ 00755c3a:1
interp_exec_method @ 00755c3a:1
interp_runtime_invoke @ 00755c3a:1
mono_jit_runtime_invoke @ 00755c3a:1
do_runtime_invoke @ 00755c3a:1
mono_runtime_try_invoke @ 00755c3a:1
mono_runtime_invoke @ 00755c3a:1
mono_wasm_invoke_method @ 00755c3a:1
Module._mono_wasm_invoke_method @ dotnet.3.2.0.js:1
call_method @ dotnet.3.2.0.js:1
(anonymous) @ dotnet.3.2.0.js:1
beginInvokeDotNetFromJS @ blazor.webassembly.js:1
s @ blazor.webassembly.js:1
e.invokeMethodAsync @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
t.dispatchEvent @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
e.onGlobalEvent @ blazor.webassembly.js:1