What is the simplest method to update a variable on the index page from a component?

SaeedP

Well-known member
Joined
Oct 21, 2020
Messages
114
Programming Experience
3-5
Hi,

I need to update a variable in my Blazor server index page when the user clicks the "upload" button in the "upload" component.

You can see my code here:

I added this code to my index page:

C#:
[Parameter] public EventCallback<bool> isConverting { get; set; }
private void UpdateParent() { isConverting.InvokeAsync(false); }

The code for the upload page includes:

C#:
[Parameter]
public EventCallback<bool> isConverting { get; set; }

When I try to use "isConverting" as a condition, I encounter an error.

C#:
@if (isConverting )
 {
     <div class="progress mt-3">
         <div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 100%"></div>
     </div>
 }


I couldn't find a satisfactory answer from AI or other resources to solve the problem.
What is your idea?

regards,
 
Read the error message that you are getting back, instead of just being blocked by "I encounter an error."

isConverting is not a bool. It's an EventCallback<bool>. An EventCallback<T> is simply a type safe wrapper struct that makes it easier to propagate events. It has no memory of what got passed in to InvokeAsync().
See the source code for it at:
 
Back
Top Bottom