01.
@page
"/counter"
02.
03.
<h1>Counter</h1>
04.
05.
<p>Current count: @currentCount</p>
06.
07.
<button
class
=
"btn btn-primary"
@onclick=
"IncrementCount"
>Click me</button>
08.
09.
<!--<Image Source=
"_imageSource"
/>-->
10.
<img src=
"@imagePath"
alt=
"Sample Image"
width=
"300px"
/>
11.
@code {
12.
13.
private
int
currentCount = 1;
14.
private
string
imagePath = @
"images\1.png"
;
15.
private
void
IncrementCount()
16.
{
17.
currentCount++;
18.
if
(currentCount>4){
19.
imagePath = @
"images\1.png"
;
20.
currentCount = 1;
21.
}
else
{
22.
imagePath = String.Format(@
"\images\{0}.png"
,currentCount);
23.
}
24.
}
25.
26.
}