Search code examples
blazorrazor-pages

Do I need to call Javascript Isolation (import) in my Razor page?


I have Blazor project, I already create a CSS isolation page & it work I dont need to call it.So now I need to use Javascript in Razor page so I create razor.js this is what I create

  1. I want to know do I need to import or call my js in my razor page ? because it seem my script did'nt working

Solution

  • You can not call javascript in your razor page like css solation (what you did), In .Net core 3 you need to reference all your javascript files inside _Host.cshtml file and in razor pages you can call the functions via IJSRuntime. In .NET 5 it improved, Now you can load your js file wherever you need and then call the functions. Take a look at this document in Microsoft doc.