locked
Blazor Server Side - UI not update RRS feed

  • Question

  • User-146938715 posted

    Hello,

    i  write a simple service class and want to show a loading spinner if the scout is running. 

    <button class="btn btn-primary" type="button" @onclick="@(() => service.Scout.Start())">
    @if (service.Scout.IsRunning)
    {
    <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
    <span>Loading...</span>
    }
    else
    {
    <span>Scout</span>
    }
    </button>
     public class Scout
      {
             public bool IsRunning { get; set; }
    }



    Tuesday, August 20, 2019 10:54 PM

Answers

  • User-146938715 posted

    I was able to solve the problem myself. Therefore I packed the problem into threads.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 23, 2019 4:57 PM

All replies

  • User711641945 posted

    Hi UrielMhezzek,

    Could you share your service.Scount.Start()?It seems to be a method?Here is a simple demo as below,it could show 'Loading' when the application starts and show 'Scout' when you click the button:

    1.Scount.cs

    public class Scout
    {
            public bool IsRunning { get; set; }
    }

    2.Test.razor

    @page "/test"
    @using BlazorServerSidetest2.Data
    <button class="btn btn-primary" type="button" @onclick="@IncrementCount">
        @if (scount.IsRunning)
        {
            <span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>
            <span>Loading...</span>
        }
        else
        {
            <span>Scout</span>
        }
    </button>
    @code {
       Scout scount = new Scout() { IsRunning = true };
    
        void IncrementCount()
        {
            scount.IsRunning = false;
        }
    }

    Best Regards,

    Rena

    Wednesday, August 21, 2019 6:29 AM
  • User-146938715 posted

    I was able to solve the problem myself. Therefore I packed the problem into threads.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 23, 2019 4:57 PM