5
Building a Local Storage Service Using JavaScript Interoperability (JS Interop)
The Blazor WebAssembly framework makes it possible for us to run C# code on the browser. However, there are some scenarios that C# simply cannot handle, and for those scenarios, we need to use JavaScript functions.
In this chapter, we will learn how to use JavaScript with Blazor WebAssembly. We will learn how to invoke a JavaScript function from a .NET method with and without a return value. Conversely, we will learn how to invoke a .NET method from a JavaScript function. We will accomplish both scenarios by using JavaScript interop (JS interop). Finally, we will learn how to store data on the browser by using the Web Storage API for JavaScript.
The project that ...
Get Blazor WebAssembly By Example - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.