We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Toast Dynamic Content Prob

Hi, I have a problem with a toast which dynamically changes the message, when you first click the button to save the object, the toast displayed is empty, on second click it displays the dynamic message.
    
private async Task CreateVehicle()
    {

        try
        {
            TanCoLogisticsSDK.Vehicle result = await VCIJ.PostVehicleAsync(Vehicle);
            this.ToastTitle = "Success";
            this.ToastContent = "Saved";
            await Task.Delay(100);
            ToastObj.Show();
        }
        catch (Exception e)
        {
            this.ToastTitle = "Error";
            this.ToastContent = "Check and retry";
            await Task.Delay(100);
            ToastObj.Show();
        }

16 Replies

PM Pandiyaraj Muniyandi Syncfusion Team August 28, 2019 11:25 AM UTC

Hi Raul, 
 
Greetings from Syncfusion support. 
 
We have validated your reported issue with shared code blocks and able to reproduce the issue from our end. The title and content variable are not updated in Toast model on update the variable dynamically until you call StateHasChanged method externally. 
 
So we suggest you to call StateHasChanged() method after title and content property values are updated like as follows 
 
 
private async Task CreateVehicle() 
    { 
        try 
        { 
            TanCoLogisticsSDK.Vehicle result = await VCIJ.PostVehicleAsync(Vehicle); 
            this.ToastTitle = "Success"; 
            this.ToastContent = "Saved"; 
            StateHasChanged(); 
            await Task.Delay(100); 
            ToastObj.Show(); 
        } 
        catch (Exception e) 
        { 
            this.ToastTitle = "Error"; 
            this.ToastContent = "Check and retry"; 
            await Task.Delay(100); 
            ToastObj.Show(); 
        } 
} 
 
 
 
We have prepared sample for your reference, get it from below link 
 
Regards, 
Pandiyaraj M 



JA Jacky December 7, 2020 09:45 AM UTC

Hi ,

I use Syncfusion.Blazor 18.3.0.51 and refer above    Sample , but Content has no change .

My main procedures are below  :

Step1 : SfToast Component has define mapping attribute.


Step2 . Declare Contents use Array Variable


Step3 : Set the Break point durning Debug the program to view variable : 
Step 3.1 . Content variable value has been changed to this.ToastContent 
Step 3.2  Set  StateHasChanged()
Step 3.3  But check the Content property value of ToastObj has not changed

Best Regards !

Jacky