Skip to content

Commit

Permalink
Cross-link 9.0 sample code (#33870)
Browse files Browse the repository at this point in the history
  • Loading branch information
guardrex authored Oct 17, 2024
1 parent 58225bd commit 3262acd
Show file tree
Hide file tree
Showing 18 changed files with 1,044 additions and 106 deletions.
40 changes: 39 additions & 1 deletion aspnetcore/blazor/components/built-in-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,45 @@ uid: blazor/components/built-in-components

The following built-in Razor components are provided by the Blazor framework. For information on non-security-related project template components, see <xref:blazor/project-structure>. For information on security-related project template components, see the [Security node articles](xref:blazor/security/index).

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

* [`AntiforgeryToken`](xref:blazor/forms/index#antiforgery-support)
* [`AuthorizeView`](xref:blazor/security/index#authorizeview-component)
* [`CascadingValue`](xref:blazor/components/cascading-values-and-parameters#cascadingvalue-component)
* [`DataAnnotationsValidator`](xref:blazor/forms/validation#data-annotations-validator-component-and-custom-validation)
* [`DynamicComponent`](xref:blazor/components/dynamiccomponent)
* [`Editor<T>`](xref:blazor/forms/binding#nest-and-bind-forms)
* [`EditForm`](xref:blazor/forms/binding#editformeditcontext-model)
* [`ErrorBoundary`](xref:blazor/fundamentals/handle-errors#error-boundaries)
* [`FocusOnNavigate`](xref:blazor/fundamentals/routing#focus-an-element-on-navigation)
* [`HeadContent`](xref:blazor/components/control-head-content)
* [`HeadOutlet`](xref:blazor/components/control-head-content)
* [`ImportMap`](xref:blazor/fundamentals/static-files#import-maps)
* [`InputCheckbox`](xref:blazor/forms/input-components)
* [`InputDate`](xref:blazor/forms/input-components)
* [`InputFile`](xref:blazor/file-uploads)
* [`InputNumber`](xref:blazor/forms/input-components)
* [`InputRadio`](xref:blazor/forms/input-components)
* [`InputRadioGroup`](xref:blazor/forms/input-components)
* [`InputSelect`](xref:blazor/forms/input-components)
* [`InputText`](xref:blazor/forms/input-components)
* [`InputTextArea`](xref:blazor/forms/input-components)
* [`LayoutView`](xref:blazor/components/layouts#apply-a-layout-to-arbitrary-content-layoutview-component)
* [`NavigationLock`](xref:blazor/fundamentals/routing#handleprevent-location-changes)
* [`NavLink`](xref:blazor/fundamentals/routing#navlink-component)
* [`PageTitle`](xref:blazor/components/control-head-content)
* [`Paginator`](xref:blazor/components/quickgrid#page-items-with-a-paginator-component)
* [`QuickGrid`](xref:blazor/components/quickgrid)
* [`Router`](xref:blazor/fundamentals/routing#route-templates)
* [`RouteView`](xref:blazor/fundamentals/routing#route-templates)
* [`SectionContent`](xref:blazor/components/sections)
* [`SectionOutlet`](xref:blazor/components/sections)
* [`ValidationSummary`](xref:blazor/forms/validation#validation-summary-and-validation-message-components)
* [`Virtualize`](xref:blazor/components/virtualization)

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

* [`AntiforgeryToken`](xref:blazor/forms/index#antiforgery-support)
* [`AuthorizeView`](xref:blazor/security/index#authorizeview-component)
Expand Down
52 changes: 49 additions & 3 deletions aspnetcore/blazor/components/cascading-values-and-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,22 @@ The following class is used in this section's examples.

`Dalek.cs`:

:::moniker-end

:::moniker range=">= aspnetcore-9.0"

:::code language="csharp" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Dalek.cs":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="csharp" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Dalek.cs":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0"

The following registrations are made in the app's `Program` file with <xref:Microsoft.Extensions.DependencyInjection.CascadingValueServiceCollectionExtensions.AddCascadingValue%2A>:

* `Dalek` with a property value for `Units` is registered as a fixed cascading value.
Expand All @@ -45,8 +59,22 @@ The following `Daleks` component displays the cascaded values.

`Daleks.razor`:

:::moniker-end

:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/Daleks.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/Daleks.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0"

In the following example, `Dalek` is registered as a cascading value using [`CascadingValueSource<T>`](xref:Microsoft.AspNetCore.Components.CascadingValueSource%601), where `<T>` is the type. The `isFixed` flag indicates whether the value is fixed. If false, all recipients are subscribed for update notifications, which are issued by calling <xref:Microsoft.AspNetCore.Components.CascadingValueSource%601.NotifyChangedAsync%2A>. Subscriptions create overhead and reduce performance, so set `isFixed` to `true` if the value doesn't change.

```csharp
Expand Down Expand Up @@ -81,7 +109,13 @@ The following `ThemeInfo` C# class specifies the theme information.
`ThemeInfo.cs`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="csharp" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/ThemeInfo.cs":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="csharp" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/ThemeInfo.cs":::

Expand Down Expand Up @@ -115,7 +149,13 @@ The following [layout component](xref:blazor/components/layouts) specifies theme

`MainLayout.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Layout/MainLayout.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Layout/MainLayout.razor":::

Expand Down Expand Up @@ -196,7 +236,13 @@ The following component binds the `ThemeInfo` cascading value to a cascading par

`ThemedCounter.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/ThemedCounter.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/ThemedCounter.razor":::

Expand Down
8 changes: 7 additions & 1 deletion aspnetcore/blazor/components/control-head-content.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ The following example sets the page's title and description using Razor.

`ControlHeadContent.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/ControlHeadContent.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/ControlHeadContent.razor":::

Expand Down
128 changes: 112 additions & 16 deletions aspnetcore/blazor/components/data-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ When an `<input>` element loses focus, its bound field or property is updated.

`Bind.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/Bind.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/Bind.razor":::

Expand Down Expand Up @@ -63,7 +69,13 @@ As a demonstration of how data binding composes in HTML, the following example b

`BindTheory.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/BindTheory.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/BindTheory.razor":::

Expand Down Expand Up @@ -99,7 +111,13 @@ Bind a property or field on other DOM events by including an `@bind:event="{EVEN

`Page/BindEvent.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/BindEvent.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/BindEvent.razor":::

Expand Down Expand Up @@ -321,7 +339,13 @@ Using `@bind:get`/`@bind:set` modifiers both controls the underlying value of `i

`DecimalBinding.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/DecimalBinding.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/DecimalBinding.razor":::

Expand Down Expand Up @@ -452,7 +476,13 @@ Consider the following component, where an `<input>` element is bound to an `int

`UnparsableValues.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/UnparsableValues.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/UnparsableValues.razor":::

Expand Down Expand Up @@ -498,7 +528,13 @@ Data binding works with a single <xref:System.DateTime> format string using `@bi

`DateBinding.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/DateBinding.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/DateBinding.razor":::

Expand Down Expand Up @@ -559,7 +595,13 @@ The following `ChildBind` component has a `Year` component parameter and an <xre

`ChildBind.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/ChildBind.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/ChildBind.razor":::

Expand Down Expand Up @@ -595,7 +637,13 @@ In the following `Parent1` component, the `year` field is bound to the `Year` pa

`Parent1.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/Parent1.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/Parent1.razor":::

Expand Down Expand Up @@ -660,7 +708,13 @@ In a more sophisticated and real-world example, the following `PasswordEntry` co

`PasswordEntry.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/PasswordEntry.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/PasswordEntry.razor":::

Expand Down Expand Up @@ -694,7 +748,13 @@ The `PasswordEntry` component is used in another component, such as the followin

`PasswordBinding.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/PasswordBinding.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/PasswordBinding.razor":::

Expand Down Expand Up @@ -733,7 +793,13 @@ Perform checks or trap errors in the handler. The following revised `PasswordEnt

`PasswordEntry.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/PasswordEntry2.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/PasswordEntry2.razor":::

Expand Down Expand Up @@ -780,7 +846,13 @@ A common and recommended approach is to only store the underlying data in the pa

`Parent2.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/Parent2.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/Parent2.razor":::

Expand Down Expand Up @@ -821,7 +893,13 @@ In the following `NestedChild` component, the `NestedGrandchild` component:

`NestedChild.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/NestedChild.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/NestedChild.razor":::

Expand Down Expand Up @@ -860,7 +938,13 @@ In the following `NestedChild` component, the `NestedGrandchild` component:

`NestedGrandchild.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/NestedGrandchild.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/NestedGrandchild.razor":::

Expand Down Expand Up @@ -900,7 +984,13 @@ The following `ChildParameterExpression` component identifies the `Year` express

`ChildParameterExpression.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/ChildParameterExpression.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/ChildParameterExpression.razor":::

Expand Down Expand Up @@ -932,7 +1022,13 @@ The following `ChildParameterExpression` component identifies the `Year` express

`Parent3.razor`:

:::moniker range=">= aspnetcore-8.0"
:::moniker range=">= aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/9.0/BlazorSample_BlazorWebApp/Components/Pages/Parent3.razor":::

:::moniker-end

:::moniker range=">= aspnetcore-8.0 < aspnetcore-9.0"

:::code language="razor" source="~/../blazor-samples/8.0/BlazorSample_BlazorWebApp/Components/Pages/Parent3.razor":::

Expand Down
Loading

0 comments on commit 3262acd

Please sign in to comment.