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 friend, Last week I wrote a full .NET 10 Web API by hand. It worked great. But I kept thinking… Can I build the same thing faster with AI? So I tried. And wow. The result blew my mind. In my new YouTube video, I show you the exact workflow I used with GitHub Copilot to build a full API. Step by step. Real code. No fluff. If you ever thought things like: ā€œHow do I use Copilot in real .NET apps?ā€ ā€œIs Copilot even helpful for Web API, EF Core, or real projects?ā€ ā€œAm I using this tool the...

video preview

Hey Reader, .NET 10 just dropped. 🄳 And if you’ve been waiting for a reason to build something new, this is it. In my latest tutorial, I’ll walk you through how to build a complete Web API from scratch in .NET 10, including: Setting up Controllers Using Entity Framework Core 10 Connecting SQL Server Working with DTOs the right way It’s perfect if you’re starting fresh or want to upgrade an older .NET 8 or .NET 9 project to the newest version. Watch the full tutorial here šŸ‘‡ Take a look, and...

video preview

Hey Reader, .NET 10 is almost here, and it brings a big upgrade for validation in Minimal APIs. In this week’s tutorial, I’ll walk you through how validation works now in .NET 10 (using Entity Framework, Scalar, and Minimal APIs). Before, writing validation logic in each endpoint was a pain. You had to manually check for null values, invalid quantities, or missing fields. But in .NET 10, that’s all built-in and super clean. Watch the full tutorial now: šŸ‘‡ Happy coding! Take care, Patrick