# Blazor ProgressBar Visible Flag

**URL:** <https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995>\
**Category:** Blazor Server\
**Created:** [March 21, 2020, 7:14pm UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995 "2020-03-21T19:14:51Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenney\_Myers](https://forum.radzen.com/user_avatar/forum.radzen.com/kenney_myers/32/2780_2.png) [@Kenney\_Myers](https://forum.radzen.com/u/Kenney_Myers)\
**Post date:** [March 21, 2020, 7:14pm UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/1 "2020-03-21T19:14:51Z")

</div>

So if I have a progressbar like so

```
           <RadzenProgressBar Value="100" ShowValue="false" Visible="@ShowProgress" Mode="ProgressBarMode.Indeterminate" Style="margin-bottom: 20px" />

```

And I want to hide/show it using the @ShowProgress variable what is the trick to making sure that when someone presses a button it shows the progress bar while a background action is taking place. I have tried it every which way but it's just not working async or sync and with or without StateHasChanged.

---

<div class="post-metadata">

**Author:** ![Kenney\_Myers](https://forum.radzen.com/user_avatar/forum.radzen.com/kenney_myers/32/2780_2.png) [@Kenney\_Myers](https://forum.radzen.com/u/Kenney_Myers)\
**Post date:** [March 21, 2020, 8:03pm UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/2 "2020-03-21T20:03:17Z")

</div>

Pretty convinced this isn't working as intended. Does anyone have an example of showing and hiding a progressbar on a button click that works?

---

<div class="post-metadata">

**Author:** ![Kenney\_Myers](https://forum.radzen.com/user_avatar/forum.radzen.com/kenney_myers/32/2780_2.png) [@Kenney\_Myers](https://forum.radzen.com/u/Kenney_Myers)\
**Post date:** [March 22, 2020, 1:02am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/3 "2020-03-22T01:02:19Z")

</div>

Okay so ... I got it to work by sticking it in an @if like so:

```
        @if (_message.Length > 0)
        {
            <RadzenProgressBar Value="100" ShowValue="false" Mode="ProgressBarMode.Indeterminate" Style="margin-bottom: 20px" />

        }

```

Then in the @code I am setting the value of the message. You could use really any variable but the main thing is to be sure to make the async calls properly so the control starts to move while your long running process is under way.

@code {

```
    private string _message = String.Empty;

    void UpdateData(MouseEventArgs e, int number)
    {
        _message = "processing";
        Task.Run(() => Refresher());
        StateHasChanged();
    }

    void Refresher()
    {
        //make your long running API call here (I injected a service for that)
        _message = String.Empty;
       //This is necessary because we are in another thread
        InvokeAsync(() => {
            StateHasChanged();
        });
    }
}

```

Might help someone, but it definitely solved my problem.

---

<div class="post-metadata">

**Author:** ![fnils](https://forum.radzen.com/user_avatar/forum.radzen.com/fnils/32/1799_2.png) [@fnils](https://forum.radzen.com/u/fnils)\
**Post date:** [April 1, 2020, 6:52am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/4 "2020-04-01T06:52:04Z")

</div>

Thank you! This is really great. I was fighting with the same problem.

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [April 1, 2020, 7:24am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/5 "2020-04-01T07:24:46Z")

</div>

I can't seem to reproduce such an issue. Toggling a page property correctly shows and hides the Progressbar.

The code essentially is:

```auto
<RadzenCheckBox @bind-Value="visible" />
<RadzenProgressBar Visible="@visible" />
@code {
  bool visible = true;
}

```

---

<div class="post-metadata">

**Author:** ![fnils](https://forum.radzen.com/user_avatar/forum.radzen.com/fnils/32/1799_2.png) [@fnils](https://forum.radzen.com/u/fnils)\
**Post date:** [April 1, 2020, 9:57am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/6 "2020-04-01T09:57:54Z")

</div>

I think for me the problem is that my "code behind" isn't a partial class. It is inherited by the frontend.  
The code behind inherits OwningComponentBase (in case this might be part of the problem).

I haven't tried changing because it is to much work and I have to little time at the moment.

---

<div class="post-metadata">

**Author:** ![mcanavar](https://forum.radzen.com/letter_avatar_proxy/v4/letter/m/ee59a6/32.png) [@mcanavar](https://forum.radzen.com/u/mcanavar)\
**Post date:** [February 3, 2022, 9:23am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/7 "2022-02-03T09:23:41Z")

</div>

@korchev  
I have the same issue:  
Click event of splitbutton "button export of crud page , added new option" .  
Added a page property with value false .  
set the page property value in the Load to false , set the page property to true in the click event of split button, then invoke a custom method .  
The custom methods runs but the progressbar doesn't show or hide .

---

<div class="post-metadata">

**Author:** ![enchev](https://forum.radzen.com/user_avatar/forum.radzen.com/enchev/32/16_2.png) [@enchev](https://forum.radzen.com/u/enchev)\
**Post date:** [February 3, 2022, 9:24am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/8 "2022-02-03T09:24:52Z")

</div>

> [@mcanavar](#):
>
> button export of crud page

The export button performs full navigation to download a file, there is no way to show progress.

---

<div class="post-metadata">

**Author:** ![mcanavar](https://forum.radzen.com/letter_avatar_proxy/v4/letter/m/ee59a6/32.png) [@mcanavar](https://forum.radzen.com/u/mcanavar)\
**Post date:** [February 3, 2022, 9:25am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/9 "2022-02-03T09:25:41Z")

</div>

Hi , I'm not using the export function .. just expanded the menu with new (extra ) option to envoke a custom method. on page.razor.cs

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [February 3, 2022, 9:29am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/10 "2022-02-03T09:29:29Z")

</div>

Setting a flag will not cause the Blazor UI to update until your method finishes execution. Check here: [Refresh a component visibility - #2 by korchev](http://forum.radzen.com/t/refresh-a-component-visibility/8710/2)

---

<div class="post-metadata">

**Author:** ![mcanavar](https://forum.radzen.com/letter_avatar_proxy/v4/letter/m/ee59a6/32.png) [@mcanavar](https://forum.radzen.com/u/mcanavar)\
**Post date:** [February 3, 2022, 9:41am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/11 "2022-02-03T09:41:06Z")

</div>

That did the trick.. now the progress works as expected ,

PS: searching the forum is quite cumbersome some times , and it is a great knowledge resource. sometimes the answers are there but difficult to find .  
Could we mark As answer , or some more tags to make this easier to find.

This suggestion for progress service has my vote::

> [@Balzor suggestion: ProgressIndicatorService?](http://forum.radzen.com/t/balzor-suggestion-progressindicatorservice/5482/2):
>
> Hi @steamonimo, Thanks for the suggestion. We will have it in mind for a future release.

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [February 3, 2022, 9:43am UTC](https://forum.radzen.com/t/blazor-progressbar-visible-flag/2995/12 "2022-02-03T09:43:22Z")

</div>

> [@mcanavar](#):
>
> Could we mark As answer , or some more tags to make this easier to find.

No. This forum software isn't stackoverflow.
