Assets

All builded files are placed inside wwwroot/assets folder and you can put all your static js, css and media files to wwwroot folder then these files could be loaded on your views.

Inline svg

Inline svg could be printed using function KTTheme.getIcon(path), this function return a content of your svg file and you can use it to display inline svg in your markup.

@((MarkupString)KTTheme.getIcon("assets/media/handcart", "svg-icon fs-3"))

Load javascript files

In Blazor you can load static js files in your views separetly by using JS.InvokeAsync function.

@inject IJSRuntime JS
@inject NavigationManager MyNavigationManager

@code {
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            await JS.InvokeAsync<IJSObjectReference>("import", MyNavigationManager.ToAbsoluteUri(“/path/to/your/file.“));
        }
    }
}

Trigger js functions from C#

In Blazor you can trigger javascript function from your C# code, this could be used to trigger js function in different component lifecycle events.

JS.InvokeVoidAsync("KTComponent.init");

Call js function with parameters.

JS.InvokeVoidAsync("KTComponent.init”, “parameters” …);
Preview Get Help Buy Now