oqtane.framework/Oqtane.Client/Skins/Controls/Mode.razor
2019-05-04 20:32:08 -04:00

45 lines
939 B
Plaintext

@using Oqtane.Skins
@using Oqtane.Shared;
@using Microsoft.JSInterop
@inject IJSRuntime jsRuntime
@inherits SkinObjectBase
<button type="button" class="btn btn-primary" onclick="@SetMode">
@displayMode
</button>
@functions {
string displayMode = "";
protected override async Task OnInitAsync()
{
var interop = new Interop(jsRuntime);
string value = await interop.GetCookie("blazor");
if (value == "client")
{
displayMode = "Server Mode";
}
else
{
displayMode = "Client Mode";
}
}
public async void SetMode()
{
var interop = new Interop(jsRuntime);
string mode = await interop.GetCookie("blazor");
if (mode == "client")
{
mode = "server";
}
else
{
mode = "client";
}
await interop.SetCookie("blazor", mode, 7);
}
}