0

I am working on a Blazor WASM project where we are using an internal HTML/JS library (a requirement that I can't get around). This library has custom events on it's components that often replace standard events. For example, the <select> control has a valuechanged event that takes the place of a standard change event (the change event is no longer emitted for this custom <select>). It also has completely custom events, such as a sort event on its <table> element.

I need to be able to work with these events, but so far have not been able to. I've tried to follow the guide here: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/event-handling?view=aspnetcore-6.0#custom-event-arguments, and gotten it set up correctly I believe (because intellisense recognizes the @on____ line), but the code to execute on those events never gets called. I'm not sure if that's because I don't have a browserEventName, or for some other reason. I've also tried the instructions here: https://stackoverflow.com/a/67595043, but again, have not had any success.

Is there a way to wire up listeners/actions to the custom events emitted in the library? The closest I've been able to find on SO to my specific issue is an unanswered question from a few years ago: How to retrieve Web Component custom event result with Blazor.

3
  • I never used the new .Net6 feature about custom events and it seems the right way to do it in Blazor. However, the second solution with JSInterop and DotNetObjectReference should be working: without code we cannot really help. Did you check that the JS function handling the event is triggered? Commented Aug 26, 2022 at 13:06
  • Please provide enough code so others can better understand or reproduce the problem. Commented Aug 26, 2022 at 17:18
  • These are links to where I capture the Dialog close event on HTML5's dialog element: github.com/BrianLParker/BlazorDialogs/blob/… github.com/BrianLParker/BlazorDialogs/blob/… Commented Aug 27, 2022 at 15:27

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.