Setting a startup page in Blazor
Just put @page “https://stackoverflow.com/” on top of your page you want to be default. Remove @page “https://stackoverflow.com/” from Index.razor @page “https://stackoverflow.com/” @page “/fetchdata”
Just put @page “https://stackoverflow.com/” on top of your page you want to be default. Remove @page “https://stackoverflow.com/” from Index.razor @page “https://stackoverflow.com/” @page “/fetchdata”
I have just implemented a State Container like this and ran into the same error – but my service needs to be a singleton. So I found an example on the aspnetcore git that does exactly what the error message says to do. Call InvokeAsync — not from your state container but when you try … Read more
Blazor doesn’t cover this scenario, for this, you would need to use CSS. It’s hard to give you a specific example as it depends on exactly how you want your animations to work and with what kind of style but I would suggest checking out CSS transitions and keyframes. Here are some good resources https://www.w3schools.com/css/css3_transitions.asp … Read more
In my opinion the main advantages of using Blazor instead of React or Angular are: C# and ASP.NET can be used both on the client and server-side. Currently the cost of switching is high (imho) and removing the need for JavaScript libraries would reduce this. It is more or less the same argument for using … Read more
I usually do something like this: Console.WriteLine(“My debug output.”); if it’s Blazor WebAssembly, I see the message in the browser´s console. If it’s Blazor Server App I see the message in the Output window. (In the output window, there is a dropdown – select: ” ASP.NET Core Web Server”).
In .NET 6 there is component called ErrorBoundary. Simple example: <ErrorBoundary> @Body </ErrorBoundary> Advanced Example: <ErrorBoundary> <ChildContent> @Body </ChildContent> <ErrorContent Context=”ex”> @{ OnError(@ex); } @*calls custom handler*@ <p>@ex.Message</p> @*prints exeption on page*@ </ErrorContent> </ErrorBoundary> For the global exception handling I see this as an option: Create CustomErrorBoundary (inherit the ErrorBoundary) and override the OnErrorAsync(Exception exception). … Read more
First you need to capture a reference of your child component: <ChildComponent @ref=”child” /> Then you can use this reference to call the child’s component methods as you do in your code. <button onClick=”@ShowModal”>show modal</button> @code{ ChildComponent child; void ShowModal(){ child.Show(); } } The namespace of your component need to be added by a using … Read more
You were close: <ChildComponent Item=”someModel” T=”SomeModel” DeleteCallback=”OnDeleteSomeModel” /> @code { SomeModel someModel = new SomeModel(); void OnDeleteSomeModel(SomeModel someModel) { … } } The EventCallback uses a generic type and blazor cannot infer it if you don’t pass the type to the component. This means that if you have a EventCallback<T> you need to pass the … Read more
For me, it was because I was using @bind-value. The v is uppercase. Use @bind-Value
A coworker of mine found the memory leak. If you disable these two checkboxes your problem is fixed. Tools -> options -> Text editor -> Advanced Disable the following: Enable pull diagnostics (experimental, requires restart) Enable razor pull diagnostics (experimental, requires restart)