Skip to content

Commit 2cf3468

Browse files
ajaybhargavbguardrex
authored andcommitted
Update blazor docs to reflect directive attributes changes (dotnet#12756)
1 parent aba1eaf commit 2cf3468

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+156
-145
lines changed

aspnetcore/blazor/common/samples/3.x/BlazorSample/Components/ChildComponent.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
<div class="panel-heading">@Title</div>
33
<div class="panel-body">@ChildContent</div>
44

5-
<button class="btn btn-primary" onclick="@OnClick">
5+
<button class="btn btn-primary" @onclick="@OnClick">
66
Trigger a Parent component method
77
</button>
88
</div>
99

10-
@functions {
10+
@code {
1111
[Parameter]
1212
private string Title { get; set; }
1313

aspnetcore/blazor/common/samples/3.x/BlazorSample/Components/HeadingComponent.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
_italicsCheck field.
2222
*@
2323
<input type="checkbox" id="italicsCheck"
24-
bind="@_italicsCheck" />
24+
@bind="@_italicsCheck" />
2525
<label class="form-check-label"
2626
for="italicsCheck">Use italics</label>
2727
</div>
@@ -30,12 +30,12 @@
3030
When the form is submitted, the onclick event executes
3131
the UpdateHeading method.
3232
*@
33-
<button type="button" class="btn btn-primary" onclick="@UpdateHeading">
33+
<button type="button" class="btn btn-primary" @onclick="@UpdateHeading">
3434
Update heading
3535
</button>
3636
</form>
3737

38-
@functions {
38+
@code {
3939
private static TextInfo _tinfo = CultureInfo.CurrentCulture.TextInfo;
4040
private string _headingText =
4141
_tinfo.ToTitleCase("welcome to blazor!");

aspnetcore/blazor/common/samples/3.x/BlazorSample/Components/ListViewTemplate.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
}
88
</ul>
99

10-
@functions {
10+
@code {
1111
[Parameter]
1212
private RenderFragment<TItem> ItemTemplate { get; set; }
1313

aspnetcore/blazor/common/samples/3.x/BlazorSample/Components/Tab.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
@implements ITab
44

55
<li>
6-
<a onclick="@Activate" class="nav-link @TitleCssClass" role="button">
6+
<a @onclick="@Activate" class="nav-link @TitleCssClass" role="button">
77
@Title
88
</a>
99
</li>
1010

11-
@functions {
11+
@code {
1212
[CascadingParameter]
1313
private TabSet ContainerTabSet { get; set; }
1414

aspnetcore/blazor/common/samples/3.x/BlazorSample/Components/TabSet.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@ActiveTab?.ChildContent
1313
</div>
1414

15-
@functions {
15+
@code {
1616
[Parameter]
1717
private RenderFragment ChildContent { get; set; }
1818

aspnetcore/blazor/common/samples/3.x/BlazorSample/Components/TableTemplate.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</tfoot>
1616
</table>
1717

18-
@functions {
18+
@code {
1919
[Parameter]
2020
private RenderFragment TableHeader { get; set; }
2121

aspnetcore/blazor/common/samples/3.x/BlazorSample/Pages/CascadingValuesParametersTabSet.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<h4>Greetings from the first tab!</h4>
99

1010
<label>
11-
<input type="checkbox" bind="@showThirdTab" />
11+
<input type="checkbox" @bind="@showThirdTab" />
1212
Toggle third tab
1313
</label>
1414
</Tab>
@@ -49,7 +49,7 @@ namespace BlazorSample.UIInterfaces
4949
&lt;h4&gt;Greetings from the first tab!&lt;/h4&gt;
5050

5151
&lt;label&gt;
52-
&lt;input type="checkbox" bind="@@showThirdTab" /&gt;
52+
&lt;input type="checkbox" @@bind="@@showThirdTab" /&gt;
5353
Toggle third tab
5454
&lt;/label&gt;
5555
&lt;/Tab&gt;
@@ -66,7 +66,7 @@ namespace BlazorSample.UIInterfaces
6666
}
6767
&lt;/TabSet&gt;
6868

69-
@@functions
69+
@@code
7070
{
7171
private bool showThirdTab;
7272
}</code></pre>
@@ -89,7 +89,7 @@ namespace BlazorSample.UIInterfaces
8989
@@ActiveTab?.ChildContent
9090
&lt;/div&gt;
9191

92-
@@functions {
92+
@@code {
9393
[Parameter]
9494
private RenderFragment ChildContent { get; set; }
9595

@@ -130,12 +130,12 @@ namespace BlazorSample.UIInterfaces
130130
@@implements ITab
131131

132132
&lt;li&gt;
133-
&lt;a onclick="@@Activate" class="nav-link @@TitleCssClass" role="button"&gt;
133+
&lt;a @@onclick="@@Activate" class="nav-link @@TitleCssClass" role="button"&gt;
134134
@@Title
135135
&lt;/a&gt;
136136
&lt;/li&gt;
137137

138-
@@functions {
138+
@@code {
139139
[CascadingParameter] private TabSet ContainerTabSet { get; set; }
140140

141141
[Parameter]
@@ -162,7 +162,7 @@ namespace BlazorSample.UIInterfaces
162162
}
163163
}</code></pre>
164164

165-
@functions
165+
@code
166166
{
167167
private bool showThirdTab;
168168
}

aspnetcore/blazor/common/samples/3.x/BlazorSample/Pages/CascadingValuesParametersTheme.razor

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<p>Current count: @currentCount</p>
88

9-
<p><button class="btn btn-primary" onclick="@IncrementCount">Increment Counter (Unthemed)</button></p>
9+
<p><button class="btn btn-primary" @onclick="@IncrementCount">Increment Counter (Unthemed)</button></p>
1010

11-
<p><button class="btn @ThemeInfo.ButtonClass" onclick="@IncrementCount">Increment Counter (Themed)</button></p>
11+
<p><button class="btn @ThemeInfo.ButtonClass" @onclick="@IncrementCount">Increment Counter (Themed)</button></p>
1212

13-
@functions {
13+
@code {
1414
private int currentCount = 0;
1515

1616
[CascadingParameter]
@@ -39,17 +39,17 @@
3939
&lt;/CascadingValue&gt;
4040
&lt;/div&gt;
4141

42-
@@functions {
42+
@@code {
4343
private ThemeInfo theme = new ThemeInfo { ButtonClass = "btn-success" };
4444
}</code></pre>
4545

4646
<p>This component (<em>CascadingValuesParametersTheme.razor</em>) receives the <code>ThemeInfo</code> as a <code>CascadingParameter</code>. The parameter is used to style one of the buttons:</p>
4747

48-
<pre><code>&lt;button class="btn" onclick="@@IncrementCount"&gt;Increment Counter (Unthemed)&lt;/button&gt;
48+
<pre><code>&lt;button class="btn" @@onclick="@@IncrementCount"&gt;Increment Counter (Unthemed)&lt;/button&gt;
4949

50-
&lt;button class="btn @@ThemeInfo.ButtonClass" onclick="@@IncrementCount"&gt;Increment Counter (Themed)&lt;/button&gt;
50+
&lt;button class="btn @@ThemeInfo.ButtonClass" @@onclick="@@IncrementCount"&gt;Increment Counter (Themed)&lt;/button&gt;
5151

52-
@@functions {
52+
@@code {
5353
private int currentCount = 0;
5454

5555
[CascadingParameter]

aspnetcore/blazor/common/samples/3.x/BlazorSample/Pages/Index.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@
4040
@@*
4141
A check box sets the font style and is bound to the _italicsCheck field.
4242
*@@
43-
&lt;input type="checkbox" id="italicsCheck" bind="@@_italicsCheck" /&gt;
43+
&lt;input type="checkbox" id="italicsCheck" @@bind="@@_italicsCheck" /&gt;
4444
&lt;label class="form-check-label" for="italicsCheck"&gt;Use italics&lt;/label&gt;
4545
&lt;/div&gt;
4646

4747
@@*
4848
When the form is submitted, the onclick event executes
4949
the UpdateHeading method.
5050
*@@
51-
&lt;button type="button" class="btn btn-primary" onclick="@@UpdateHeading"&gt;
51+
&lt;button type="button" class="btn btn-primary" @@onclick="@@UpdateHeading"&gt;
5252
Update heading
5353
&lt;/button&gt;
5454
&lt;/form&gt;
5555

56-
@@functions {
56+
@@code {
5757
private static TextInfo _tinfo = CultureInfo.CurrentCulture.TextInfo;
5858
private string _headingText = _tinfo.ToTitleCase("welcome to blazor!");
5959
private string _headingFontStyle = "normal";

aspnetcore/blazor/common/samples/3.x/BlazorSample/Pages/JSInterop.razor

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77

88
<h2>Invoke JavaScript functions from .NET methods</h2>
99

10-
<button type="button" class="btn btn-primary" onclick="@TriggerJsPrompt">
10+
<button type="button" class="btn btn-primary" @onclick="@TriggerJsPrompt">
1111
Trigger JavaScript Prompt
1212
</button>
1313

1414
<h3 id="welcome" style="color:green;font-style:italic"></h3>
1515

16-
@functions {
16+
@code {
1717
public async void TriggerJsPrompt()
1818
{
1919
// showPrompt is implemented in wwwroot/exampleJsInterop.js
@@ -48,11 +48,11 @@
4848

4949
<!-- <snippet_JSInterop2> -->
5050
<button type="button" class="btn btn-primary"
51-
onclick="exampleJsFunctions.returnArrayAsyncJs()">
51+
@onclick="exampleJsFunctions.returnArrayAsyncJs()">
5252
Trigger .NET static method ReturnArrayAsync
5353
</button>
5454

55-
@functions {
55+
@code {
5656
[JSInvokable]
5757
public static Task<int[]> ReturnArrayAsync()
5858
{
@@ -62,11 +62,11 @@
6262
<!-- </snippet_JSInterop2> -->
6363

6464
<!-- <snippet_JSInterop3> -->
65-
<button type="button" class="btn btn-primary" onclick="@TriggerNetInstanceMethod">
65+
<button type="button" class="btn btn-primary" @onclick="@TriggerNetInstanceMethod">
6666
Trigger .NET instance method HelloHelper.SayHello
6767
</button>
6868

69-
@functions {
69+
@code {
7070
public async void TriggerNetInstanceMethod()
7171
{
7272
var exampleJsInterop = new ExampleJsInterop(JSRuntime);

0 commit comments

Comments
 (0)