Manage InputSelect form options for SSR (#31438)
parent
bf565c20d5
commit
f9113050da
|
@ -5,7 +5,7 @@ description: Learn about built-in Blazor input components.
|
|||
monikerRange: '>= aspnetcore-3.1'
|
||||
ms.author: riande
|
||||
ms.custom: mvc
|
||||
ms.date: 01/05/2024
|
||||
ms.date: 01/12/2024
|
||||
uid: blazor/forms/input-components
|
||||
---
|
||||
# ASP.NET Core Blazor input components
|
||||
|
@ -123,6 +123,8 @@ The following form accepts and validates user input using:
|
|||
* The properties and validation defined in the preceding `Starship` model.
|
||||
* Several of Blazor's built-in input components.
|
||||
|
||||
When the model property for the ship's classification (`Classification`) is set, the option matching the model is checked. For example, `checked="@(Model!.Classification == "Exploration")"` for the classification of an exploration ship. The reason for explicitly setting the checked option is that the value of a `<select>` element is only present in the browser. If the form is rendered on the server after it's submitted, any state from the client is overridden with state from the server, which doesn't ordinarily mark an option as checked. By setting the checked option from the model property, the classification always reflects the model's state. This preserves the classification selection across form submissions that result in the form rerendering on the server. In situations where the form isn't rerendered on the server, such as when the Interactive Server render mode is applied directly to the component, explicit assignment of the checked option isn't necessary.
|
||||
|
||||
`Starship3.razor`:
|
||||
|
||||
:::moniker range=">= aspnetcore-8.0"
|
||||
|
|
|
@ -5,7 +5,7 @@ description: Learn how to use validation in Blazor forms.
|
|||
monikerRange: '>= aspnetcore-3.1'
|
||||
ms.author: riande
|
||||
ms.custom: mvc
|
||||
ms.date: 01/05/2024
|
||||
ms.date: 01/12/2024
|
||||
uid: blazor/forms/validation
|
||||
---
|
||||
# ASP.NET Core Blazor forms validation
|
||||
|
|
Loading…
Reference in New Issue