Blazor page no longer updates after publication

Viewed 20

I not quite experience within Blazor and run into a problem. I use this code within a razor page to create a dropdown:

        <select name="Gruppe">
            <option value="-1" @onclick=@(() => GetVideosByGroup(-1)) @onclick:preventDefault="true">Alle</option>

            @foreach (var group in _content)
            {
                <option value="@group.SubjectId" @onclick=@(() => GetVideosByGroup(group.SubjectId)) @onclick:preventDefault="true">@group.Name</option>
            }
        </select>

Within the code section I refresh the Page after selection changed:

@code {
    ...
    private List<Content>? _subjects;
    ...
    private async Task GetVideosByGroup(int groupId)
    {
        if (groupId == -1)
        {
            _subjects = await ContentsService.GetContentList();
        }
        else
        {
            _subjects = await ContentsService.GetContentListBySubject(groupId);
        }
    }
}

This runs fine within local execution. After publishing online, the page do not refresh anymore (all other Parts still works as expected). Even explicite calling of StateHasChange does take effect.

Have one any Idea or hints where to look for? The complete code also is available at GitHub (Razor Page on GitHub).

Thanks in advance

1 Answers

I've found the answear:

Some Browsers have Problems with the "click event" in combination with Blazor Server Side. After using "change event", everything was fine.

Have a look here (The Problem) and here (A Solution for change event)

By the way: using the attribute "multiple" also fixed the problem but wouldn't look nice.

Related