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
}
} |