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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Toast Dynamic Content Prob

Thread ID:

Created:

Updated:

Platform:

Replies:

146988 Aug 27,2019 07:16 PM UTC Aug 28,2019 11:25 AM UTC Blazor 1
loading
Tags: Toast
Raul
Asked On August 27, 2019 07:16 PM UTC

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();
        }

Pandiyaraj Muniyandi [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon