Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions aspnetcore/blazor/components/quickgrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ To use Entity Framework (EF) Core as the data source:
builder.Services.AddQuickGridEntityFrameworkAdapter();
```

QuickGrid supports passing custom attributes to the the rendered table element:

```razor
<QuickGrid Items="..." custom-attribute="somevalue" class="custom-class">
```

:::moniker-end

:::moniker range="< aspnetcore-8.0"
Expand Down
11 changes: 11 additions & 0 deletions aspnetcore/blazor/components/render-modes.md
Original file line number Diff line number Diff line change
Expand Up @@ -458,3 +458,14 @@ You also typically must set the same interactive render mode on the `HeadOutlet`
> In an upcoming preview release, a template option for the Blazor Web App template to create the app with root-level interactivity.

<!-- UPDATE 8.0 The preceding is tracked by https://github.com/dotnet/aspnetcore/issues/50433 -->

## Discover components from additional assemblies for static server rendering

Configure additional assemblies to use for discovering routable Razor components for static server rendering using the `AddAdditionalAssemblies` method chained to <xref:Microsoft.AspNetCore.Builder.RazorComponentsEndpointRouteBuilderExtensions.MapRazorComponents%2A>.

The following example includes the assembly of the `DifferentAssemblyCounter` component:

```csharp
app.MapRazorComponents<App>()
.AddAdditionalAssemblies(typeof(DifferentAssemblyCounter).Assembly);
```
25 changes: 25 additions & 0 deletions aspnetcore/blazor/forms-and-input-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,31 @@ Control the style of validation messages in the app's stylesheet (`wwwroot/css/a
}
```

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

## Determine if a form field is valid

<!-- UPDATE 8.0 API cross-link -->

Use `EditContext.IsValid(fieldIdentifier)` to determine if a field is valid without obtaining validation messages.

<span aria-hidden="true">❌</span> Supported, but not recommended:

```csharp
var isValid = !editContext.GetValidationMessages(fieldIdentifier).Any();
```

<span aria-hidden="true">✔️</span> Recommended:

```csharp
var isValid = editContext.IsValid(fieldIdentifier);
```

> [!NOTE]
> Custom validation examples in this article call <xref:Microsoft.AspNetCore.Components.Forms.EditContext.GetValidationMessages%2A> on the edit context to determine if a field is valid. An issue has been opened at [Update Blazor form custom validation examples 8.0 (dotnet/AspNetCore.Docs #30338)](https://github.com/dotnet/AspNetCore.Docs/issues/30338) to update the examples to use the new API. We recommend using the new `EditContext.IsValid` API in your own code, but the approach with <xref:Microsoft.AspNetCore.Components.Forms.EditContext.GetValidationMessages%2A> is still supported and doesn't result in a runtime error if testing the article's examples.

:::moniker-end

## Custom validation attributes

To ensure that a validation result is correctly associated with a field when using a [custom validation attribute](xref:mvc/models/validation#custom-attributes), pass the validation context's <xref:System.ComponentModel.DataAnnotations.ValidationContext.MemberName> when creating the <xref:System.ComponentModel.DataAnnotations.ValidationResult>.
Expand Down
4 changes: 3 additions & 1 deletion aspnetcore/blazor/fundamentals/startup.md
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ In `wwwroot/index.html`, remove the default SVG round indicator in `<div id="app

## Configure the .NET WebAssembly runtime

To configure the .NET WebAssembly runtime, use the `configureRuntime` property with the `dotnet` runtime host builder.
To configure the .NET WebAssembly runtime, use the `configureRuntime` function with the `dotnet` runtime host builder.

The following example sets an environment variable, `CONFIGURE_RUNTIME`, to `true`:

Expand All @@ -479,6 +479,8 @@ The following example sets an environment variable, `CONFIGURE_RUNTIME`, to `tru

In the preceding example, the `{BLAZOR SCRIPT}` placeholder is the Blazor script path and file name.

The .NET runtime instance can be accessed from `Blazor.runtime`.

:::moniker-end

## Additional resources
Expand Down
27 changes: 27 additions & 0 deletions aspnetcore/blazor/host-and-deploy/webassembly.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,33 @@ The size of an AOT-compiled Blazor WebAssembly app is generally larger than the
> [!NOTE]
> For [Mono](https://github.com/mono/mono)/WebAssembly MSBuild properties and targets, see [`WasmApp.targets` (dotnet/runtime GitHub repository)](https://github.com/dotnet/runtime/blob/main/src/mono/wasm/build/WasmApp.targets). Official documentation for common MSBuild properties is planned per [Document blazor msbuild configuration options (dotnet/docs #27395)](https://github.com/dotnet/docs/issues/27395).

:::moniker-end

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

## Trim .NET IL after ahead-of-time (AOT) compilation

The `WasmStripILAfterAOT` MSBuild option enables removing the .NET Intermediate Language (IL) for compiled methods after performing AOT compilation to WebAssembly, which reduces the size of the `_framework` folder.

In the app's project file:

```xml
<PropertyGroup>
<RunAOTCompilation>true</RunAOTCompilation>
<WasmStripILAfterAOT>true</WasmStripILAfterAOT>
</PropertyGroup>
```

This setting trims away the IL code for most compiled methods, including methods from libraries and methods in the app. Not all compiled methods can be trimmed, as some are still required by the .NET interpreter at runtime.

<!-- UPDATE 8.0 Remove the next line after some time has passed -->

If you hit any issues using this trimming option, [open an issue on the `dotnet/runtime` GitHub repository](https://github.com/dotnet/runtime/issues).

:::moniker-end

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

## Runtime relinking

One of the largest parts of a Blazor WebAssembly app is the WebAssembly-based .NET runtime (`dotnet.wasm`) that the browser must download when the app is first accessed by a user's browser. Relinking the .NET WebAssembly runtime trims unused runtime code and thus improves download speed.
Expand Down
8 changes: 7 additions & 1 deletion aspnetcore/blazor/project-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ Blazor Web App project template: `blazor`

Project structure:

If both the WebAssembly and Server render modes are selected on app creation, the project template uses the Auto render mode. The Auto render mode initially uses the Server mode while the .NET app bundle and runtime are download to the browser. After the .NET WebAssembly runtime is activated, Auto switches to the WebAssembly render mode.

By default, the Blazor Web App template enables both static and interactive server rendering using a single project. If you also enable the WebAssembly render mode, the project includes an additional client project (`.Client`) for your WebAssembly-based components. The built output from the client project is downloaded to the browser and executed on the client. Any components using the WebAssembly or Auto render modes must be built from the client project.

For more information, see <xref:blazor/components/render-modes>.

<!-- UPDATE 8.0 Check on Error page setup per
https://github.com/dotnet/aspnetcore/issues/49853 -->

Expand Down Expand Up @@ -57,7 +63,7 @@ Project structure:

* App settings files (`appsettings.Development.json`, `appsettings.json`): Provide [configuration settings](xref:blazor/fundamentals/configuration) for the server project.

* Client project: `.Client`
* Client project (`.Client`):

* `Pages` folder: Contains the app's routable client-side Razor components (`.razor`). The route for each page is specified using the [`@page`](xref:mvc/views/razor#page) directive. The template includes `Counter` component (`Counter.razor`) that implements the *Counter* page.

Expand Down
10 changes: 9 additions & 1 deletion aspnetcore/blazor/tooling.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@ To create a Blazor app on Windows, use the following guidance:
<!-- UPDATE 8.0 Cross-link SSR -->

* For a Blazor Web App in the **Additional information** dialog:

* Interactivity with server rendering is enabled by default with the **Use interactive server components** checkbox.
* To enable interactivity with client rendering, select the **Use interactive client components** checkbox.
* To enable interactivity with client rendering, select the **Use interactive WebAssembly components** checkbox.
* To include sample pages and a layout based on Bootstrap styling, select the **Include sample pages** checkbox. Disable this option for an empty project without Bootstrap styling.

If both the WebAssembly and Server render modes are selected, the template uses the Auto render mode. The Auto render mode initially uses the Server mode while the .NET app bundle and runtime are download to the browser. After the .NET WebAssembly runtime is activated, Auto switches to the WebAssembly render mode.

By default, the Blazor Web App template enables both static and interactive server rendering using a single project. If you also enable the WebAssembly render mode, the project includes an additional client project (`.Client`) for your WebAssembly-based components. The built output from the client project is downloaded to the browser and executed on the client. Any components using the WebAssembly or Auto render modes must be built from the client project.

For more information, see <xref:blazor/components/render-modes>.

<!-- UPDATE 8.0 I think the interactive root component checkbox
will appear at RC2. -->
Expand Down