vikramlearning / blazorbootstrap

An Enterprise-class Blazor Bootstrap Component library built on the Blazor and Bootstrap CSS frameworks.
https://docs.blazorbootstrap.com/
Apache License 2.0
665 stars 32 forks source link

Using Blazor Bootstrap with .Net 8 Server Side Rendering (Specifically Toast) #587

Open HowardShank opened 6 months ago

HowardShank commented 6 months ago

I am attempting to incorporate the library into our new .Net 8 Blazor Server Side application. We are initially wanting to utilize the Toast component. And then add more components as we build the app.

I have 2 scenarios, one works and the other does not.

The service is registered in program.cs per the instructions. All the css is configured per the instructions. All the js scripts are configured per the instructions.

Note: Services.Toast.ToastMessage inherits BlazorBootstrap.ToastMessage. That is successful in scenario 1.

Scenario 1: works I am using the following code to call notify in both my working and non-working scenarios:

        Services.Toast.ToastMessage toastMessage = new Services.Toast.ToastMessage(ToastType.Primary, "Component loaded.");
        blazorBootstrapToastService.Notify(toastMessage);

I have successfully incorporated a component into a single component. The element exists in my rendered output: <div id="AR1BT7RLPMED3" class="toast-container position-fixed top-0 start-50 translate-middle-x p-3" _bl_bb61f423-937b-4b2e-acbf-840007556fbe=""></div> In my component I can use both the Messages property with a List property and with the injected service @inject BlazorBootstrap.ToastService ToastService.

Scenario 2: does not work I am unable to incorporate a component into the MainLayout.razor or our inherited custom base AppLayout.razor page. Calling the ToastService.Notify() method does not throw any exceptions, the messages just do not show on the screen. The element exists in my rendered page. <div id="AR1BT7RLPMEDP" class="toast-container position-fixed top-0 end-0 p-3"></div> It appears there is no communication to it notifying it to display a message when the component is in my layout page.

I'm unsure where to go from here.

Thank you for your assistance in advance.

mxmissile commented 5 months ago

does your MainLayout have @rendermode InteractiveServer?