razor icon indicating copy to clipboard operation
razor copied to clipboard

Confused by error message regarding attribute syntax

Open pekspro opened this issue 6 years ago • 4 comments

I’ve just started to play around with Blazor and tried to write this code in a .razor-file:

<span class="@if(sortType != 0) { <text>btn-primary</text> } else { <text>btn-success</text> }">

Yes, not very elegant :-) Either way, I got this error message that confuses me:

Code blocks delimited by '@{...}' like '@{ if(sortType != 0) { } }' for attributes are no longer supported These features have been changed to use attribute syntax. Use 'attr="@(x => {... }"'.

I’ve tried to rewrite me code to use lambda expression as suggested, but whatever I do a get an error message. Is this possible in this case? I’ve noticed that a lambda expression works fine if the attribute is @onclick.

If I rewrite my code like this it works, but that is not was the error message suggest:

<span class="btn @(sortType != 0 ? "btn-primary" : "btn-success")">

pekspro avatar Aug 10 '19 10:08 pekspro

We've moved this issue to the Backlog milestone. This means that it is not going to happen for the coming release. We will reassess the backlog following the current release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources.

mkArtakMSFT avatar Aug 12 '19 16:08 mkArtakMSFT

Moving this to .NET 7 planning if and only if this is just a matter of changing the error description. Otherwise, there's limited community engagement for this issue to pursue a more complex solution.

TanayParikh avatar Oct 19 '21 01:10 TanayParikh

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Oct 21 '21 22:10 ghost

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Nov 08 '23 02:11 ghost