When we have a HTML code like below.
<h1>@Title</h1>
and C# like below
public string Title { get; set; }
Think I have executed a code like below
Title = "New title updated in the runtime";
Then we see that the view has chenged with the new value.
How the renderer knows that the property value has changes.
Is there anything like INotifyProperyChange
is implemented. How the HTML knows that this is the time to update the content.
I just want to know how the internals of the Blazor Framework are architectured.
To use two-way binding on a parameter simply prefix the HTML attribute with the text @bind- . This tells Blazor it should not only push changes to the component, but should also observe the component for any changes and update its own state accordingly.
Yes, Blazor is ready to be used in production, it is a life changer, Blazor is a framework that optimizes development speed, helps considerably reducing code duplication and inconsistencies between front-end and api/backend models, and in turn it helps reducing bugs and development costs, in top of that, since Blazor ...
Blazor, which conveniently is a short form of browser + razor, is a relatively new Microsoft web framework that was released in 2018. Similar to Angular, Blazor is both open source and free. The framework enables developers to build interactive and reusable web UI in existing web technologies like C# or HTML.
StateHasChanged notifies the component that its state has changed. When applicable, calling StateHasChanged causes the component to be rerendered. StateHasChanged is called automatically for EventCallback methods. For more information on event callbacks, see ASP.NET Core Blazor event handling.
Blazor automatically checks for changes of bound properties when a user interaction happened (e.g. button click, text in an input changed). In that case, Blazor's JavaScript code triggers change detection in C# (=Webassembly). Therefore, you do not need to do anything if you want to refresh the UI after a user interaction.
However, there are cases in which you want to refresh the UI although no user interaction happened (e.g. timer). In that case, you have to call StateHasChanged
. I have created a more detailed example on learn-blazor.com.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With