-
Book Overview & Buying
-
Table Of Contents
Web Development with Blazor - Fourth Edition
By :
I would argue that calling .NET code from JavaScript isn't a very common scenario, and if we find ourselves in that scenario, we might want to think about what we are doing.
As Blazor developers, we should avoid using JavaScript as much as possible.
I am not bashing JavaScript in any way, but I see this often happens where developers use what they used before and kind of shoehorn it into their Blazor project.
They end up solving things with JavaScript that could have been a simple if statement in Blazor.
This often happens because that was the only option before. In traditional web development, if we wanted to show or hide something, react to events, or update the UI, JavaScript was the tool we had. So it's easy to fall back into that habit.
In Blazor, we already have that logic in C#. We can use conditions, event handlers, and binding directly in our components instead of reaching for JavaScript.
So, it's important to think about when JavaScript is actually...