Created
March 7, 2021 22:37
-
-
Save justinyoo/adf1539f817c4b604c5cedc421e96aed to your computer and use it in GitHub Desktop.
Blazor Code-behind
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/counter" | |
<h1>Counter</h1> | |
<p>Current count: @currentCount</p> | |
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> | |
@code { | |
private int currentCount = 0; | |
private void IncrementCount() | |
{ | |
currentCount++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Counter | |
{ | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Counter | |
{ | |
private int currentCount = 0; | |
private void IncrementCount() | |
{ | |
currentCount++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CounterBase : ComponentBase | |
{ | |
private int currentCount = 0; | |
private void IncrementCount() | |
{ | |
currentCount++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/counter" | |
@inherits CounterBase | |
<h1>Counter</h1> | |
<p>Current count: @currentCount</p> | |
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CounterBase : ComponentBase | |
{ | |
protected int CurrentCount { get; set; } = 0; | |
protected void IncrementCount() | |
{ | |
this.CurrentCount++; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CounterBase : ComponentBase | |
{ | |
protected int CurrentCount { get; set; } = 0; | |
protected void IncrementCount() | |
{ | |
this.CurrentCount++; | |
} | |
protected override async Task OnInitializedAsync() | |
{ | |
this.CurrentCount = 10; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/counter" | |
@inherits CounterBase | |
<h1>Counter</h1> | |
<p>Current count: @CurrentCount</p> | |
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class Counter : ComponentBase | |
{ | |
protected int CurrentCount { get; set; } = 0; | |
protected void IncrementCount() | |
{ | |
this.CurrentCount++; | |
} | |
protected override async Task OnInitializedAsync() | |
{ | |
this.CurrentCount = 10; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@page "/counter" | |
<h1>Counter</h1> | |
<p>Current count: @CurrentCount</p> | |
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment