Set EventCallback outside of a Blazor component?

Turns out you can assign an event callback from C# code like this: this.ProgressManager.UpdateNotification = new EventCallback(this, (Action)Refresh); void Refresh() {} It also works with async methods, e.g.: this.ProgressManager.UpdateNotification = new EventCallback(this, (Func<ValueTask>)RefreshAsync); ValueTask RefreshAsync() {} UPDATE You can also use EventCallbackFactory to more conveniently create event callback objects, e.g.: new EventCallbackFactory().Create(this, Refresh)

How to set page title in blazor?

From ASP.NET CORE 6.0, the official docs says that we can Influence HTML <title> tag elements easily by using PageTitle component. Add the HeadOutlet Component in Program.cs builder.RootComponents.Add<HeadOutlet>(“head::after”); Then use PageTitle Component <PageTitle>@title</PageTitle> Update 1: Looks like this API has been put on hold to improve further. This has been removed from official docs link. … Read more

How can I open a new window without using JS

As of 1 of June 2022 there is no way of currently doing it directly with pure Blazor, you’ll need to use JSInterop. Luckily this is easy enough to do. At the top of your .razor file add @inject IJSRuntime JSRuntime; And then use it like so await JSRuntime.InvokeAsync<object>(“open”, url, “_blank”); Note that the IJSRuntime … Read more

How to set the focus to an InputText element?

In .NET5 it will be much simpler: <button @onclick=”() => textInput.FocusAsync()”>Set focus</button> <input @ref=”textInput”/> @code { ElementReference textInput; } NOTE: this feature was introduced in .NET5 Preview 8 so might change until the final release! Also worth mentioning that in .NET5 RC1 JavaScript isolation was introduced via JS Module export/import. So if you still need … Read more

Blazor onclick event is not triggered

This answer is only for .net 8, where static rendering is the default. .net 8 introduced the notion of Render Modes, and it is now required either at the page level, or globally. The default is static rendering which means that the component is rendered exactly as it is written with no interactivity being wired … Read more

Multiple Startup projects in Solution, in Rider

In the run config drop down, select “Edit Configuration…” At the top of the left hand menu, click “+” Find and select “Compound” Name it Use the “+” button to add the projects you’d like to start together Select that configuration when you run it Edit the confuration: Find and select the Compound configuration: Add … Read more

Blazor, ASP.NET Core Hosted vs Server Side in ASP.NET Core

I think the accepted answer does not answer the question asked like Mike-EEE mentioned in one of the comments. The necessary information can be found under this link: https://www.telerik.com/blogs/a-breakdown-of-blazor-project-types The Blazor Full-Stack template encompasses the same project structure as the Client-Side template with a few additions. Just like the Client-Side template there is no HTML … Read more