Comments (6)
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.
the name john smith doesnt display. anything i do in the OnAfterRenderAysnc doest change the UI
from sessionstorage.
first thing i actually noticed that i changed
protected override async Task OnAfterRenderAsync() does not exist
So im actually using
protected override async Task OnAfterRenderAsync(bool firstRender)
from sessionstorage.
`@page "/counter"
@Inject Blazored.SessionStorage.ISessionStorageService sessionStorage
Counter
Current count: @currentCount
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.
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.
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)
- Is this a good use library to store the JWT and deal with AuthenticationStateProvider? HOT 1
- [Question] Using System.Text.Json.JsonSerializer.SerializeToUtf8Bytes HOT 3
- [Bug] Session Storage Limit HOT 6
- [Feature Request] Cancellation Token support HOT 1
- Could the dependency on bUnit.Core be removed? HOT 1
- [Bug]GetItemAsync and SetItemAsync throw System.Threading.Tasks.TaskCanceledException: 'A task was canceled.' HOT 2
- [Feature Request] .NET6 HOT 2
- [Feature Request] TestExtensions - ISyncSessionStorageService HOT 1
- [Question] Serialize internal properties? HOT 1
- "Duplicate Tab" issue. HOT 1
- Session ID HOT 3
- [Bug]Different Blazor Server apps on same web server can share session values HOT 3
- [Bug] SetItemAsync throws Microsoft.JSInterop.JSDisconnectedException: JavaScript interop calls cannot be issued at this time. HOT 1
- AddBlazoredSessionStorage() add public setter for options.JsonSerializerOptions
- [Bug] SessionStorage Value Not Persisting on Page Refresh HOT 1
- How do I removed a variable stored in local storage from a Blazor Server App? HOT 3
- [Question] Does accessing session storage work in `OnInitializedAsync` with render mode `Server(prerender=false)`?
- blazored.sessionstorage is missing NuGet package README file
- session.GetItemAsync("authToken") - does not return the value nor does it throw an exception
- [Question] Get sessions values in ASP Controllers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sessionstorage.