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

Cannot bind to style when binding to events #16055

Closed
rpedretti opened this issue May 7, 2018 · 8 comments
Closed

Cannot bind to style when binding to events #16055

rpedretti opened this issue May 7, 2018 · 8 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@rpedretti
Copy link

I'm using Blazor 0.3.0 and whenever I bind to an event any bind to 'style' breaks.

I have a sample app at https://github.com/rpedretti/BlazorApp on branch version_0_3_0 that the bug can be reproduced, but I guess it' happens in any project

Given a simple tag like

<p onmouseover="@ViewModel.OnComponentHover"
  style="background: @ViewModel.ParentBgColor;" />

The compiler throws

Error Component attributes do not support complex content (mixed C# and markup). Attribute: 'style', text 'background:ViewModel.ParentBgColor;

and even the intellisense breakes:
image

By removing any of the properties the project compiles beautifully and intellisense works again.

image

@dlr1
Copy link

dlr1 commented May 7, 2018

this is a known issue, it works in 0.4.0
aspnet/Blazor#753

@rpedretti rpedretti changed the title Cannot bind to style when binding to evets Cannot bind to style when binding to events May 7, 2018
@SteveSandersonMS
Copy link
Member

Actually I no longer thing this is fixed in 0.4.0. Needs more investigation.

@rpedretti
Copy link
Author

Do you need more info?

@SteveSandersonMS
Copy link
Member

No, the repro info above is sufficient. Thanks for reporting it! We'll investigate.

@rynowak
Copy link
Member

rynowak commented May 9, 2018

I'll take a look at this.

@rynowak rynowak self-assigned this May 9, 2018
rynowak referenced this issue in dotnet/blazor May 22, 2018
The logic that binds event handlers was interfering with the code that
prevents component properties from receiving complex content.

This check was a little overzealous.
@rynowak
Copy link
Member

rynowak commented May 22, 2018

This should be fixed in dev as part of the upcoming 0.4 release

@vargonian
Copy link

vargonian commented Sep 11, 2018

I'm using 0.5.1 and still having this issue. In my case it's happening when using a BlazorStrap Image component. I notice that if I use a plain HTML img the problem goes away.

@danroth27
Copy link
Member

@vargonian Please open an issue with your steps for reproducing the issue and we'll take a look.

SteveSandersonMS referenced this issue in SteveSandersonMS/BlazorMigration Nov 27, 2018
The logic that binds event handlers was interfering with the code that
prevents component properties from receiving complex content.

This check was a little overzealous.
@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

7 participants