Skip to content

JavaScript InterOp Error : Can't find JavaScript function #58071

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice]
Blazor/Wasm .Net8 VS 20

C#callJsEer.png
22 community 17.11.4

"showAlert" JavaScript functon can't not be found in wwwroot/JScripts/SiteScript.js
by the standard coding scheme

  1. Index.html
<body>
    <script src="_framework/blazor.webassembly.js"></script>
    <script src="JScripts/SiteScript.js"></script>
</body>
  1. In wwwroot/JScripts/SiteScript.js file
function showAlert(name) {
    alert('Hello ' + name);
}
  1. In Register.razor
    protected override async Task OnInitializedAsync()
    {
        await JSRuntime.InvokeVoidAsync("showAlert", "Unkown user");
        //await JSRuntime.InvokeVoidAsync("EnableAllSubDivs", "EditUser");
    }

Original Comments

Feedback Bot on 9/19/2024, 06:35 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Author: Migration Bot 🤖The issue was created by a issue mover bot. The author may not be the actual author.Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.Needs: ReproIndicates that the team needs a repro project to continue the investigation on this issuearea-blazorIncludes: Blazor, Razor Componentsfeature-blazor-jsinteropThis issue is related to JSInterop in Blazor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions