Articles in this section
Category / Section

How to update the progress bar value when submitting in Blazor Progress Bar?

2 mins read

This article explains how to update the progress bar value when submitting in Blazor Progress Bar.

Update Progress Bar Value in the OnValidSubmit Method

Blazor Progress Bar provides an option to update progress bar value in the OnValidSubmit method.

To update the progress bar value in the OnValidSubmit method, you need to invoke the “StateHasChanged” method when updating the progress bar’s in-between values.

The below code example demonstrates how to update progress bar value in the OnValidSubmit method.

Index.razor

@using Syncfusion.Blazor.ProgressBar
@using Syncfusion.Blazor.Buttons

<EditForm Model="@model" OnValidSubmit="@OnValidSubmit">

   <div class="submit-btn">

       <SfButton type="submit" style="color: Black; text-transform: capitalize;">Submit</SfButton>

   </div>

   <SfProgressBar Type="ProgressType.Linear" Height="40" CornerRadius="CornerType.Round" Width="100%" ShowProgressValue="true" Value="@ProgressValue" Minimum="0" Maximum="100" Visible="@Visible">
   </SfProgressBar>

</EditForm>

@code{
   public int ProgressValue { get; set; }
   public bool Visible { get; set; } = false;
   public UserProfileModel model { get; set; } = new UserProfileModel();

   public class UserProfileModel
   {
       public string Name { get; set; }
       public string Email { get; set; }
   }

   async Task OnValidSubmit()
   {
       this.Visible = true;
       this.ProgressValue = 10;

       this.ProgressValue = 20;
       StateHasChanged();

       await Task.Delay(5000);
       this.ProgressValue = 50;
       StateHasChanged();

       await Task.Delay(5000);
       this.ProgressValue = 70;
   }
} 

The following screenshot illustrates the output of the code snippet.

chrome_DCLKzWSmLJ.png

chrome_VA5709mDtF.png

chrome_yDeg89XYPJ.png

Conclusion

I hope you enjoyed learning how to update progress bar value in the OnValidSubmit method in Blazor Progress Bar.

You can refer to our Blazor Progress Bar feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our Blazor Progress Bar to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, support portal, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied