Handle scenario where an event handler was specified as the wrong type #5473
Labels
affected-medium
This issue impacts approximately half of our customers
area-blazor
Includes: Blazor, Razor Components
bug
This issue describes a behavior which is not expected - a bug.
feature-razor.language
severity-minor
This label is used by an internal tool
Milestone
Originally reported in #135
Currently if you declare an event handler with
onsomeevent=@something
, and@something
isn't aUIEventHandler
, then at runtime when the event is triggered, you will getThere is no event handler with ID 0
. This is because we only assign event handler IDs when the attribute value is the type we recognize (UIEventHandler
).Options:
@onclick(...)
cover this already, because they are defined to accept aUIEventHandler
, and the compiler will automatically create one of those for you if you try to pass a compatibleAction<UIEventArgs>
or similar. Or we could have tag helper-type infrastructure that limits what values you can give for all attributes whose names correspond to known HTML events.Cannot trigger event handler for {eventname} because is not of the correct type. Event handlers must be of type UIEventHandler; you supplied {othertype}.
The text was updated successfully, but these errors were encountered: