79140867

Date: 2024-10-30 11:25:22
Score: 0.5
Natty:
Report link

So, here I am, 2 days later, having understood that the problem was entirely somewhere else.

In the same page, I have a Grid Component, where one of the GridColumns was defined as:

<GridColumn TItem="AnaAddressBooks" Context="chContext" HeaderText="@Localizer[LocalTranslations.Customers_AddressbookDefaultRole_Lbl]">
    @if (chContext.FK_Cls_DefaultUserRole.Equals(ClsUsersRoles.OBSERVER)) {
        <i class="fa-solid fa-binoculars"></i>
    }
    @if (chContext.FK_Cls_DefaultUserRole.Equals(ClsUsersRoles.SUBCONTRACTOR)) {
        <i class="fa-solid fa-wrench"></i>
    }
</GridColumn>

After commenting it out, I discovered that the error was disappearing.

Turns out, if I transformed the GridColumn like this:

<GridColumn TItem="AnaAddressBooks" Context="chContext" HeaderText="@Localizer[LocalTranslations.Customers_AddressbookDefaultRole_Lbl]" >
    @if (chContext.FK_Cls_DefaultUserRole.Equals(ClsUsersRoles.OBSERVER)) {
        <div>
            <i class="fa-solid fa-binoculars"></i>
        </div>
    }
    @if (chContext.FK_Cls_DefaultUserRole.Equals(ClsUsersRoles.SUBCONTRACTOR)) {
        <div>
            <i class="fa-solid fa-wrench"></i>
        </div>
    }
</GridColumn>

,embedding the two FontAwesome icons each in a div element, the error was gone.

Note that embedding the entire @if in a div, like this:

<GridColumn TItem="AnaAddressBooks" Context="chContext" HeaderText="@Localizer[LocalTranslations.Customers_AddressbookDefaultRole_Lbl]">
    <div>
        @if (chContext.FK_Cls_DefaultUserRole.Equals(ClsUsersRoles.OBSERVER))     {
            <i class="fa-solid fa-binoculars"></i>
        }
        @if (chContext.FK_Cls_DefaultUserRole.Equals(ClsUsersRoles.SUBCONTRACTOR)) {
            <i class="fa-solid fa-wrench"></i>
        }
    </div>
</GridColumn>

still wouldn't work and would give the same error.

Edit: In the end I was partially inspired by this StackOverflow thread that featured a similar error

Reasons:
  • Blacklisted phrase (1): StackOverflow
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Guido De Vecchi