aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Cannot bind to style when binding to events

Open rpedretti opened this issue 8 years ago • 8 comments

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

rpedretti avatar May 07 '18 13:05 rpedretti

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

dlr1 avatar May 07 '18 14:05 dlr1

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

SteveSandersonMS avatar May 08 '18 15:05 SteveSandersonMS

Do you need more info?

rpedretti avatar May 08 '18 15:05 rpedretti

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

SteveSandersonMS avatar May 08 '18 15:05 SteveSandersonMS

I'll take a look at this.

rynowak avatar May 09 '18 03:05 rynowak

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

rynowak avatar May 22 '18 18:05 rynowak

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.

vargonian avatar Sep 11 '18 18:09 vargonian

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

danroth27 avatar Sep 14 '18 23:09 danroth27