Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
150892 | Jan 23,2020 12:05 PM UTC | Apr 2,2020 10:37 AM UTC | Blazor | 2 |
![]() |
Tags: Tabs |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace TabComponent
{
public class CounterState
{
public int CurrentCount { get; set; }
}
} |
// ** SESSION STATE
// Singleton usually means for all users,
// where as scoped means for the current unit-of-work
services.AddScoped<CounterState>();
|
@inject CounterState CounterState
<EjsTab>
---------
----------
<ContentTemplate>
<div class="active">
<input value="@CounterState.CurrentCount" /> // Get input value
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
</div>
</ContentTemplate>
-----------
-----------
</EjsTab>
@code{
public void IncrementCount()
{
int CurrentCount = CounterState.CurrentCount; // set session state
CurrentCount++;
CounterState.CurrentCount = CurrentCount; // set current count on session state object
}
} |
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.