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, You sit down to build an API, add some authentication, and think, “JWT should do the trick.” But then you wonder: What happens if my JWT gets stolen? How do I keep users logged in without compromising security? Sound familiar? In my latest video, I show you how to implement secure JWT authentication with short-lived tokens and refresh tokens in .NET. This setup minimizes risk while keeping the user experience seamless. No fluff - just practical, real-world guidance for building...

Hey Reader, Tired of factories and messy if-else logic in your projects? Since .NET 8, Keyed Services make it easy to handle multiple implementations. No more clutter - just clean, scalable code. In my new video, you’ll see how to dynamically pick services using a key and write code that’s easy to extend. It’s a fresh, modern approach to dependency injection that’ll have you rethinking how you design your APIs. 👉 Watch the video here Wishing you a fantastic start to the new year filled with...

video preview

Hey Reader, You sit down to write an API, and before you know it, you’re knee-deep in controllers, attributes, and boilerplate. Sound familiar? What if you could skip all that and still build a fully functional API - fast? That’s where Minimal APIs in .NET come in. They’re clean and lightweight and make building APIs feel like a breeze. In my latest video, I show you how to set up endpoints step by step and structure everything neatly so your code stays easy to read and scale. No fluff - just...