Forms with .NET 8 Blazor SSR (Static Server-Side Rendering) & Enhanced Navigation🔥


Hey Reader,

A common query I come across is about handling forms in Blazor Static Server-Side Rendering (SSR). Is it feasible to use Blazor's default EditForm without engaging any new interactive render modes? Absolutely, it is.

🔥 Latest Tutorial on YouTube

I've put together a detailed guide on how to effectively utilize the EditForm, along with the traditional HTML form element. This allows for the use of buttons independent of a model. Plus, I’ll walk you through enhanced navigation techniques like fixing the scroll position for a smoother user experience. Check it out!

video preview

💻 Quick Summary

To employ the EditForm in Blazor SSR, it's crucial to implement the new FormName parameter in the EditForm component and incorporate the [SupplyParameterFromForm] attribute in your model. For handling multiple forms, you’ll need to specify the form name as well.

If your goal is to integrate a button without tying it to a model (a requirement in the EditForm) and bypass interactive render modes like Server or WebAssembly, simply encase it within a standard HTML form tag.

In a scenario where this form is within a foreach loop, notice how I’ve assigned a distinct name to each form using the character.Name property. This is essential for uniqueness, just like in the EditForm. Don’t forget to include the AntiforgeryToken component and observe how enhanced navigation is achieved by adding data-enhance. For the EditForm, just add Enhance, and you're all set.

That's it for today, Reader.

Hope you have a fantastic weekend!


Any queries or need further explanations? Feel free to respond to this email, and I’ll be more than happy to create additional tutorials for your assistance.

A huge shoutout to our amazing community and a massive thank you to my Patrons for your unwavering support. You are the true heroes of this newsletter and my channel. Looking forward to our continued journey this year.

Stay healthy, and always remember, the fun is in the coding! 💻

Take care,

Patrick


Patrick God

Become a .NET & Blazor expert with weekly tutorials featuring best practices and the latest improvements, right in your inbox.

Read more from Patrick God
video preview

Hey Reader, Ever tried to choose the perfect weapon for each creature in a dark, spooky forest? Silver bullets for werewolves, garlic for vampires, chainsaws for zombies... but what if you had to pick your weapon before entering the forest? Just like that forest adventure, dependency injection in C# can leave you stuck with the wrong tool when you need it most - unless you know about the Factory Pattern! Today, I’m breaking down how the Factory Pattern solves real-world dependency injection...

video preview

Hey Reader, In today’s tutorial, I’ll walk you through how to use Dapper, a high-performance micro ORM (object-relational mapper) with a .NET 8 Web API and SQL Server. We’ll cover everything you need to know to build a simple CRUD (Create, Read, Update, Delete) application. Watch on YouTube 📺 Check out the full tutorial on YouTube to see everything in action 👇 What We’ll Be Doing We’re going to work with a simple video game database to start. You’ll learn how to: Read all games or a specific...

video preview

Hey Reader, Today, I show you how combining Blazor and JavaScript can give you the best of both worlds. Let’s dive into how you can easily mix the power of these two technologies in your projects! Watch on YouTube 📺 Check out the full tutorial on YouTube to see everything in action 👇 A Simple Example: Console Logging in Blazor Imagine you’re working on a Blazor Server application, and you want to log the current count (of the Counter page) to the console. Your first thought might be to use...