Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any fix for Error BL9986: Component attributes do not support complex content (mixed C# and markup). #16079

Closed
talkingdotnet opened this issue May 4, 2018 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@talkingdotnet
Copy link

I am trying to upgrade one of my blazor app built on 0.1 (CRUD App using Blazor) to 0.3 but I am getting the "Error BL9986: Component attributes do not support complex content (mixed C# and markup). " I understand the error but not able to find the solution. This used to work previously.

<input id="[email protected]" style="display:none;">

But now it gives me mixed c# and markup error. How would such use cases needs to be handled. Another practical use case is of applying CSS class to the element like,

<button class="btn btn-success @(SelectedID == todo.ID ? "ShowControl" : "HideControl")"> Update </button>

This also gives me the same error but interestingly it works for the HTML span element. The following code works,
<span id="[email protected]">@todo.Item</span>

Any ideas how to fix this error and why Blazor is not allowing this.

@SteveSandersonMS
Copy link
Member

Sorry for the inconvenience. This is already fixed in our dev branch so should be resolved in 0.4.0.

In the meantime one workaround is to make the whole attribute a single C# expression, e.g.:

<input id="@($"txt_{todo.ID}")" style="display:none;">

@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/blazor Oct 27, 2019
@mkArtakMSFT mkArtakMSFT added the area-blazor Includes: Blazor, Razor Components label Oct 27, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Dec 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

3 participants