From 4c8a60ec961ea4301a3de50159505217bf28dc03 Mon Sep 17 00:00:00 2001 From: guardrex <1622880+guardrex@users.noreply.github.com> Date: Mon, 17 Nov 2025 09:41:00 -0500 Subject: [PATCH 1/2] Access modifiers for cascading params --- .../blazor/components/cascading-values-and-parameters.md | 6 ++++-- .../class-libraries-and-static-server-side-rendering.md | 2 +- aspnetcore/blazor/components/httpcontext.md | 2 +- aspnetcore/blazor/fundamentals/handle-errors.md | 6 +++--- aspnetcore/blazor/fundamentals/routing.md | 2 +- aspnetcore/blazor/globalization-localization.md | 4 ++-- aspnetcore/blazor/hybrid/root-component-parameters.md | 2 +- aspnetcore/blazor/security/content-security-policy.md | 2 +- 8 files changed, 14 insertions(+), 12 deletions(-) diff --git a/aspnetcore/blazor/components/cascading-values-and-parameters.md b/aspnetcore/blazor/components/cascading-values-and-parameters.md index 09a8e69d20ef..9990efffc5dc 100644 --- a/aspnetcore/blazor/components/cascading-values-and-parameters.md +++ b/aspnetcore/blazor/components/cascading-values-and-parameters.md @@ -241,7 +241,7 @@ The following component is used to demonstrate how changing the value of `Notify private int dalekCount; [CascadingParameter] - public NotifyingDalek? Dalek { get; set; } + private NotifyingDalek? Dalek { get; set; } private void Update() { @@ -433,6 +433,8 @@ For more information, see the following sections of this article: To make use of cascading values, descendent components declare cascading parameters using the [`[CascadingParameter]` attribute](xref:Microsoft.AspNetCore.Components.CascadingParameterAttribute). Cascading values are bound to cascading parameters **by type**. Cascading multiple values of the same type is covered in the [Cascade multiple values](#cascade-multiple-values) section later in this article. +The `private` access modifier is recommended for components because the parameter should be scoped for use only in the component's class in most cases. When subclassing is required, use the `protected` access modifier. + The following component binds the `ThemeInfo` cascading value to a cascading parameter, optionally using the same name of `ThemeInfo`. The parameter is used to set the CSS class for the **`Increment Counter (Themed)`** button. `ThemedCounter.razor`: @@ -657,7 +659,7 @@ Descendent `Tab` components capture the containing `TabSet` as a cascading param @code { [CascadingParameter] - public TabSet? ContainerTabSet { get; set; } + private TabSet? ContainerTabSet { get; set; } [Parameter] public string? Title { get; set; } diff --git a/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md b/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md index e5699f5be141..655ac45d200b 100644 --- a/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md +++ b/aspnetcore/blazor/components/class-libraries-and-static-server-side-rendering.md @@ -125,7 +125,7 @@ Reusable components are free to receive an Date: Mon, 17 Nov 2025 09:49:22 -0500 Subject: [PATCH 2/2] Update aspnetcore/blazor/components/cascading-values-and-parameters.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- aspnetcore/blazor/components/cascading-values-and-parameters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/blazor/components/cascading-values-and-parameters.md b/aspnetcore/blazor/components/cascading-values-and-parameters.md index 9990efffc5dc..68c0a96128fa 100644 --- a/aspnetcore/blazor/components/cascading-values-and-parameters.md +++ b/aspnetcore/blazor/components/cascading-values-and-parameters.md @@ -433,7 +433,7 @@ For more information, see the following sections of this article: To make use of cascading values, descendent components declare cascading parameters using the [`[CascadingParameter]` attribute](xref:Microsoft.AspNetCore.Components.CascadingParameterAttribute). Cascading values are bound to cascading parameters **by type**. Cascading multiple values of the same type is covered in the [Cascade multiple values](#cascade-multiple-values) section later in this article. -The `private` access modifier is recommended for components because the parameter should be scoped for use only in the component's class in most cases. When subclassing is required, use the `protected` access modifier. +The `private` access modifier is recommended for cascading parameters because the parameter should be scoped for use only within the component's class in most cases. When subclassing is required, use the `protected` access modifier. The following component binds the `ThemeInfo` cascading value to a cascading parameter, optionally using the same name of `ThemeInfo`. The parameter is used to set the CSS class for the **`Increment Counter (Themed)`** button.