Skip to content

Add Onclick event for JS #16267

@msdickinson

Description

@msdickinson

Add Ablity to use onclick to call JS Functions instead of just c# methods.

Assuming I am understanding it correctly, onclick cant be used to call a JS function, and can only be used to call a C# method.
Currently I would need to have it call a C# method and then have it call a JS Function.

When Adding The Code Below to cshtml page like index.cshtml, It throws in error.
Uncaught Error: System.ArgumentException: There is no event handler with ID 0

I created default blazor template, and added this code to index.cshtml
<input type="button" onclick="demoFunction()" /><script> function demoFunction() {}</script>`

"version": "2.1.300-preview1-008174"

https://github.com/aspnet/Blazor/blob/4608caa7e016dbcc7c69cca167a58199c3e78a3d/src/Microsoft.AspNetCore.Blazor.Browser.JS/src/Rendering/BrowserRenderer.ts#L185-L191

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions