Live Chat Icon For mobile
Live Chat Icon

What if the Blazor anchor tag executes href instead of an onclick event?

Platform: Blazor| Category: Event handling

Yes, this is a known issue in Blazor. You can track the issue link on Github.

This is how to prevent an href in an anchor tag and call an onclick event. [Work Around]

<a href="https://www.youtube.com/watch?v=kX4oRfj1Ip8" class="btn btn-primary" @onclick="@TheEvent"  @onclick:preventDefault>Do it</a>

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.