Uncaught (in promise) Error: System.ArgumentException: There is no event handler associated with this event. EventId: '4'"

Viewed 1368

Issue Description

When using bind attribute and onblur event on the input element cause Uncaught (in promise) Error: System.ArgumentException: There is no event handler associated with this event. EventId: '4.

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/BlazorApp531274741370

Replication procedure

  1. Run the sample
  2. Click the Navigate button for go to Counter page
  3. Then enter anything in the TextBox which is rendered in the Counter page
  4. Now, press the back button on chrome browser.
  5. Now, see the console for error

Screenshot

Click here to view the error screenshot

Error

Uncaught (in promise) Error: System.ArgumentException: There is no event handler associated with this event. EventId: '4'. (Parameter 'eventHandlerId')
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)
   at Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo eventFieldInfo, EventArgs eventArgs)
   at Microsoft.AspNetCore.Components.WebAssembly.Infrastructure.JSInteropMethods.DispatchEvent(WebEventDescriptor eventDescriptor, String eventArgsJson)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
--- End of stack trace from previous location ---
   at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.InvokeSynchronously(JSRuntime jsRuntime, DotNetInvocationInfo& callInfo, IDotNetObjectReference objectReference, String argsJson)
   at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime jsRuntime, DotNetInvocationInfo invocationInfo, String argsJson)
    at Object.endInvokeDotNetFromJS (https://localhost:44389/_framework/blazor.webassembly.js:1:4191)
    at Object.invokeJSFromDotNet (https://localhost:44389/_framework/blazor.webassembly.js:1:3797)
    at Object.w [as invokeJSFromDotNet] (https://localhost:44389/_framework/blazor.webassembly.js:1:64075)
    at _mono_wasm_invoke_js_blazor (https://localhost:44389/_framework/dotnet.5.0.0.js:1:190800)
    at do_icall (<anonymous>:wasm-function[10595]:0x194e46)
    at do_icall_wrapper (<anonymous>:wasm-function[3305]:0x79df6)
    at interp_exec_method (<anonymous>:wasm-function[2155]:0x44ad0)
    at interp_runtime_invoke (<anonymous>:wasm-function[7861]:0x12efed)
    at mono_jit_runtime_invoke (<anonymous>:wasm-function[7346]:0x118e4d)
    at do_runtime_invoke (<anonymous>:wasm-function[3304]:0x79d3f)

Code Snippet

<input @bind="val" @onblur="blurevent" />

@code{​​​​​​​
    public void blurevent(FocusEventArgs args)
    {​​​​​​​

    }​​​​​​​

    public string val {​​​​​​​ get; set; }​​​​​​​
}​​​​​​​

1 Answers

I found a solution to this one here

Basically adding : private async Task Callback(KeyboardEventArgs args) { --code-- await Task.Yield(); --code-- } Fixes the issue.

It is said it will be fixed in .Net 6

Related