David Bowser
David Bowser

Reputation: 107

Using Blazor <InputSelect> gives warning: Element 'option' cannot be nested inside element 'p'

I am trying to follow the pattern from Microsoft's site: https://learn.microsoft.com/en-us/aspnet/core/blazor/forms-validation?view=aspnetcore-3.0 here is a snippet of their code ...

<p>
        <label for="classification">Primary Classification: </label>
        <InputSelect id="classification" @bind-Value="@starship.Classification">
            <option value="">Select classification ...</option>
            <option value="Defense">Defense</option>
            <option value="Exploration">Exploration</option>
            <option value="Diplomacy">Diplomacy</option>
        </InputSelect>
</p>

I get a warning on each of my 'option' tags saying they cannot be nested inside element 'p'. Their example above gives the same warning :p

How do I eliminate that warning? I am using VS Pro 2019 Ver 16.2.0 Preview 3.0 updated 6/26/2019. Their example is from 06/13/2019 so also pretty recent.

Also their example is a .cshtml file but most examples I see use .razor extension. I tried changing mine to .cshtml and got the same warning. Which should I use or does it not matter?

Upvotes: 2

Views: 2443

Answers (1)

enet
enet

Reputation: 45724

This is a known issue you should just ignore... See: https://github.com/aspnet/AspNetCore/issues/8166

View the .g.cs files in your project, and see if the compiler is creating the render tree properly. Perhaps the issues lies there...

Hope this helps...

Upvotes: 2

Related Questions