You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the writeup @dotnet/AspNetCore.Docs#21763 for checking custom event args feature in Blazor - "Register custom event handlers in DOM and handle those in .NET".
But unable to get the custom events triggered from custom elements handled in .NET.
To Reproduce
Environment:
.NET 6.0 RC
Microsoft Visual Studio Community 2022 Preview (64-bit)
Version 17.0.0 Preview 4.1
What I did?
index.html
<script>Blazor.registerCustomEventType('closed',{createEventArgs: {customProperty1: 'any value for property 1'}});</script>
<custom-control@onclosed="HandleCustomEvent">Handle</custom-control>
@code{voidHandleCustomEvent(CustomEventArgseventArgs)
{// here you can access the data which was passed in from the Javascript side}}
Now, whenever the custom event ("closed") is fired by custom-control, my event handler is not getting called. Anything I am missing, do you have a working sample?
The text was updated successfully, but these errors were encountered:
ghost
added
Needs: Attention 👋
This issue needs the attention of a contributor, typically because the OP has provided an update.
and removed
Needs: Author Feedback
The author of this issue needs to respond in order for us to continue investigating this issue.
labels
Sep 28, 2021
I just checked, and the feature does work. What's missing in your code is that your [EventHandler] class can't be found by the compiler because it's nested inside a .razor class. You need to move it out into a regular .cs file so it can become a normal top-level class. Also make sure it's public and is in a namespace that's imported to the .razor file you're trying to use the event inside.
Once you have this correct, you should see it light up in purple in the tooling.
Describe the bug
I followed the writeup @dotnet/AspNetCore.Docs#21763 for checking custom event args feature in Blazor - "Register custom event handlers in DOM and handle those in .NET".
But unable to get the custom events triggered from custom elements handled in .NET.
To Reproduce
Environment:
.NET 6.0 RC
Microsoft Visual Studio Community 2022 Preview (64-bit)
Version 17.0.0 Preview 4.1
What I did?
Further technical details
dotnet --info
Now, whenever the custom event ("closed") is fired by custom-control, my event handler is not getting called. Anything I am missing, do you have a working sample?
The text was updated successfully, but these errors were encountered: