Description
This is an impactful enough change that it needs its own docs information in preview 9. This is a summary for now, and I'll write detailed guidance later.
Summary
In 3.0-preview9 and later, the set of bindings and event handlers available for HTML elements are defined in the Microsoft.AspNetCore.Components.Web
assembly and based on the Microsoft.AspNetCore.Components.Web
namespace.
Migration Guidance
Blazor WebAssembly and Libraries
When migrating an application to preview 9 or later, make sure to add a reference to the Microsoft.AspNetCore.Components.Web
nuget package. Next, open the application's root _Imports.razor
and add @using Microsoft.AspNetCore.Components.Web
.
Blazor Server-Side
When migrating an application to preview 9 or later, open the application's root _Imports.razor
and add @using Microsoft.AspNetCore.Components.Web
.
note: Server-Side Blazor applications get a reference to Microsoft.AspNetCore.Components.Web
implicitly without any additional package references.
Troubleshooting guidance
With the correct references and @using
, event handlers like @onclick
and @bind
should be bold font, and colorized as shown below when using Visual Studio.
If @bind
or @onclick
is colorized as a normal HTML attribute, like the below, then the @using
is missing.
You may also see errors like:
CS0169 The field 'Index.text' is never used
CS0428 Cannot convert method group 'Submit' to non-delegate type 'object'. Did you intend to invoke the method?
Try adding @using Microsoft.AspNetCore.Components.Web
to the file. If you now see an error like the following, this means that the reference to the Microsoft.AspNetCore.Components.Web
package is missing from the project.
CS0234 The type or namespace name 'Web' does not exist in the namespace 'Microsoft.AspNetCore.Components' (are you missing an assembly reference?)
If adding the using fixed the problem, consider moving to the application's root _Imports.razor
so it will apply to all files.
Metadata
Metadata
Assignees
Type
Projects
Status