Created
November 9, 2019 13:46
-
-
Save shadow-cs/b3a39769e249f3b116c1b4f41dcb2bda 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
namespace CodeBehindTest.Pages | |
{ | |
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
@page "/counter" | |
<h1>Counter</h1> | |
<p>Current count: @currentCount</p> | |
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> |
Oh sure I did try that on 3.1 and VS Preview (just didn't have time to watch the videos fast enough), thanks for the heads up ;-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yep, support for partial classes was enabled in .NET Core 3.1 and will be the recommended pattern going forward. But if you're using .NET Core 3.0, then you'll need to use a base class due to issues with how the Razor tooling works.