@page "/"
<div class="mbb-background">
<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
</div>
<style type="text/css">
:root {
--background-image: url(@image);
}
.mbb-background {
background-image: var(--background-image);
background-repeat: no-repeat;
background-size: cover;
}
</style>
@functions {
int currentCount = 0;
string image=String.Empty;
void IncrementCount()
{
currentCount++;
if(currentCount % 2 == 0){
image = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/a9/Example.jpg/116px-Example.jpg";
}
else{
image = "https://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Example.png/116px-Example.png";
}
}
}