GithubHelp home page GithubHelp logo

Comments (6)

chrissainty avatar chrissainty commented on May 22, 2024

I can't see any obvious reason this code shouldn't work. What errors are you seeing? Have you stepped through the code while debugging? If so what happened?

from sessionstorage.

ojorma avatar ojorma commented on May 22, 2024

the name john smith doesnt display. anything i do in the OnAfterRenderAysnc doest change the UI

from sessionstorage.

ojorma avatar ojorma commented on May 22, 2024

first thing i actually noticed that i changed
protected override async Task OnAfterRenderAsync() does not exist
image

So im actually using
protected override async Task OnAfterRenderAsync(bool firstRender)

image

from sessionstorage.

ojorma avatar ojorma commented on May 22, 2024

`@page "/counter"
@Inject Blazored.SessionStorage.ISessionStorageService sessionStorage

Counter

Current count: @currentCount

@name

Click me

@functions {
private int currentCount = 0;
private string Name;
private void IncrementCount()
{
currentCount++;
}

   protected override async Task OnAfterRenderAsync(bool firstRender)

{
    await sessionStorage.SetItemAsync("name", "John Smith");
    var name = await sessionStorage.GetItemAsync<string>("name");
    Name = name;
    base.OnAfterRender(firstRender);
}

}
`

from sessionstorage.

chrissainty avatar chrissainty commented on May 22, 2024

I doubt this is having an effect on anything but you shouldn't be using functions, that is a Razor Pages feature. For Blazor components you should be using code.

Could you try adding a StateHasChanged call after you set the Name property.

from sessionstorage.

ojorma avatar ojorma commented on May 22, 2024

StateHasChanged, that did it. me using code and functions is just me trying everything i can think of. Thanks problem solved.

from sessionstorage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.