Skip to content

Handle scenario where an event handler was specified as the wrong type #5473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SteveSandersonMS opened this issue Feb 19, 2018 · 2 comments
Closed
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

Comments

@SteveSandersonMS
Copy link
Member

Originally reported in #135

Currently if you declare an event handler with onsomeevent=@something, and @something isn't a UIEventHandler, then at runtime when the event is triggered, you will get There 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:

  • Handle it at compile time. Helpers like @onclick(...) cover this already, because they are defined to accept a UIEventHandler, and the compiler will automatically create one of those for you if you try to pass a compatible Action<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.
  • Handle it better at runtime. If you try to raise an event and the corresponding handler attribute didn't have an event handler ID, report something like Cannot trigger event handler for {eventname} because is not of the correct type. Event handlers must be of type UIEventHandler; you supplied {othertype}.
@SteveSandersonMS SteveSandersonMS changed the title Handle scenario where an event handler is the wrong type Handle scenario where an event handler was specified as the wrong type Feb 19, 2018
@aspnet-hello aspnet-hello transferred this issue from dotnet/blazor Dec 17, 2018
@aspnet-hello aspnet-hello added this to the Backlog milestone Dec 17, 2018
@aspnet-hello aspnet-hello added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. area-blazor Includes: Blazor, Razor Components labels Dec 17, 2018
@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@SteveSandersonMS SteveSandersonMS added affected-medium This issue impacts approximately half of our customers severity-minor This label is used by an internal tool labels Oct 14, 2020 — with ASP.NET Core Issue Ranking
@javiercn javiercn added feature-razor.language reevaluate We need to reevaluate the issue and make a decision about it labels Apr 19, 2021
@TanayParikh TanayParikh modified the milestones: Backlog, .NET 7 Planning Oct 19, 2021
@TanayParikh TanayParikh removed the reevaluate We need to reevaluate the issue and make a decision about it label Oct 19, 2021
@TanayParikh TanayParikh modified the milestones: .NET 7 Planning, Backlog Oct 21, 2021
@ghost
Copy link

ghost commented Oct 21, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@mkArtakMSFT
Copy link
Contributor

Hi. Thanks for contacting us.
We're closing this issue as there was not much community interest in this ask for quite a while now.
You can learn more about our triage process and how we handle issues by reading our Triage Process writeup.

@mkArtakMSFT mkArtakMSFT closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Projects
None yet
Development

No branches or pull requests

5 participants