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

Hey Reader, Last week, I tested GPT-5 Agent Mode on .NET and Blazor apps, and the results were surprising. This week, I went a step further. I used GitHub Copilot inside Visual Studio and asked it to create real .NET and Blazor projects for me. Here’s what happened: Copilot generated a working calculator app in C#. It built a Web API that responded with ā€œHello GPT-5 Agents.ā€ It even created a Blazor app with extra features like a reset button, a plus five counter, and a weather API. Were...

video preview

Hey Reader, I just published a new video where I put GPT-5’s Agent Mode to the test. šŸš€ Instead of asking it for something simple, I went all in: A .NET 9 console app calculator A Web API with endpoints and docs A Blazor Server app with extra counter buttons And even a Blazor app that calls a public weather API šŸŽ„ Watch it now: In the video, I didn’t just type ā€œmake me an appā€ and hope for the best. I gave GPT-5 very specific prompts, like: ā€œPlease create a .NET 9 console application that works...

Hey Reader, I’m back! šŸŽ‰ I’ve been on parental leave for the past 2 months, enjoying time with the family. Now I’m diving back into videos and here’s the first one! šŸŽ„ Watch it now: Here’s the TL;DR if you can’t click right now: AI can already write code, fix bugs, and explain complex concepts. So… are we doomed? No. AI isn’t replacing developers anytime soon. But: Developers who use AI will replace those who don’t. The best devs are using GPT to: Skip repetitive work Prototype faster Learn...