blazorbootstrap icon indicating copy to clipboard operation
blazorbootstrap copied to clipboard

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

Open HowardShank opened this issue 4 months ago • 1 comments

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 <Toasts /> 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<ToastMessage> property and with the injected service @inject BlazorBootstrap.ToastService ToastService.

Scenario 2: does not work I am unable to incorporate a <Toasts /> 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.

HowardShank avatar Feb 22 '24 21:02 HowardShank

does your MainLayout have @rendermode InteractiveServer?

mxmissile avatar Mar 21 '24 22:03 mxmissile