Hi
My project is currently using .net 7.0 and setup for Blazor Server
Disclaimer, this is my first ever Blazor project and its all quite new to me, so this could easily be my lack of understanding.
I've added a toast component as per the instructions here: https://blazor.syncfusion.com/documentation/toast/config#show-or-hide-toast-using-service so I can re-use this by injecting it into any component, however I am experiencing an issue where whilst the toast component works, there are a few glitches.
Attachment: ToastService_(2)_f18deb.zip
Hi, thank you for the attachment, howeer I can confirm that the attached isn't working as I thought it would.
I made a slight modification to the code you gave me to help make the issue clear
I've updated line 15 in Index.razor file to now read
Content = $"Toast content {DateTime.Now}", // Dynamic Content
This now puts the date and time in the toast, if you press this button repeatedly, you will see it does not stack the messages with the date/time but replaces the content in ALL visible toasts to the same date/time.
So when I have my app perhaps raise 2 toasts depending on an action, it will replace the first with the new content and leave them both on screen?
Thanks
Phill
The reason the toast is being shown everywhere is because the documentation falsely initialized the toast service as a singleton instead of scoped. You want it to be scoped because each HTTP request (basically each web page for a single user) has it's own notification service.
The sample provided by Vinitha did actually solve this issue without explaining it.
For those still curious about this issue, I created by own support ticket following up about multi toasts: 183972
Hi Jonah Largen,
We apologize for any inconvenience you've experienced due to the incorrect initialization of the toast service as a singleton in our documentation. Thank you for bringing this to our attention. We take your feedback seriously and are committed to rectifying this issue.
We want to assure you that we are actively working on correcting the documentation to accurately reflect the correct approach, and the updated version will be included in one of our upcoming releases. We truly appreciate your patience and understanding as we address this matter.
Regards,
Kokila Poovendran.