question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blazor Server-Side not re-rendering component after event is fired !

See original GitHub issue

As described in the title,i can’t see any re-rendering after ‘onclick’ is fired

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core ‘3 preview 7’
  2. Run this code
protected virtual void BuildCompnent(RenderTreeBuilder builder)
{
...

builder.AddContent(seq, _viewProperty.PropertyValue ?? "--SELECT--");

...

     foreach (var item in SelectionDictionary)
                    {                   
                        builder.OpenElement(++seq, "a");
                        builder.AddAttribute(seq, "class", "font-weight-light btn-sm dropdown-item " + (item.Value == _viewProperty.PropertyValue ? "active" : ""));
                        builder.AddAttribute(seq, "onclick", () => ItemClicked?.Invoke(item.Key)); 
                        //builder.SetUpdatesAttributeName("onclick"); --> tried it but no help
                        builder.AddContent(seq, item.Value.ToString());
                        builder.CloseElement();
                   }
...
}
  1. The Action ‘ItemClicked’ is reached by the debugger , but component not showing “re-rendering” the selected item

Expected behavior

It should re-render the component by default when ‘onclick’ event is fired

Additional context

BTW this code was working like a charm in blazor 0.7 server-side but after updating to latest version…things got crackly

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
SteveSandersonMScommented, Aug 12, 2019

how could i know the future ?! like how many item in SelectionDictionary ?!

In the linked blog post, it explains how you should handle this to avoid the seq++ code.

0reactions
msftbot[bot]commented, Dec 6, 2019

Thank you for contacting us. Due to no activity on this issue we’re closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn’t been addressed yet, please file a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor component not refresh after event fired
The problem is, when I fire ItemSelected event, the class of the <tr> is not updated, however when I remove the line ItemSelected....
Read more >
State Hasn't Changed? Why and when Blazor components ...
Here are the primary reasons your component will re-render: After an event occurs (when invoking an event handler in the same component); After ......
Read more >
ASP.NET Core Blazor performance best practices
The event is dispatched to the component that rendered the event's handler. After executing the event handler, the component is rerendered. When ...
Read more >
How to run code after Blazor component has rendered
This blog post will show you how to run code after your Blazor component has rendered, on every render or as needed. Sample...
Read more >
Why is Blazor's rendering so inefficient?
The culprits were mainly over rendering too many things after events were fired (e.g re-rendering whole grid for unrelated field changes), as ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found