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.
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!
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
Become a .NET & Blazor expert with weekly tutorials featuring best practices and the latest improvements, right in your inbox.
Hey Reader, After 15 years of building web apps, I just recently discovered Vertical Slice Architecture. I know. I’m late to the party. But wow, this approach really changed how I think about structuring Blazor projects. So I decided to show you a simple, real-world example of how to use Vertical Slice Architecture in a Blazor Server app. 🎥 Watch the full tutorial now: In this new tutorial, you'll learn: ✅ How to structure your app with feature folders ✅ How to avoid overcomplicating things...
Hey Reader, In my last videos, we built a solid CRUD API using Vertical Slice Architecture, Minimal APIs, and Carter - super clean and modern. But there’s still one problem... 👉 What happens when a user sends empty or invalid data? In this new YouTube tutorial, I’ll show you how to fix that with: And yep, the full source code is free to download. Just check the link in the video description. If you’ve been enjoying this Vertical Slice series, this is a must-watch. It’s a simple upgrade that...
Hey Reader, If you're building apps with Blazor, you've probably asked yourself this: 👉 Should I use SSR, Blazor Server, or WebAssembly? It’s a common question - and I get it a lot. So I made a brand-new YouTube video walking you through how to choose the best one for your app. 🎥 Watch it here: If you're building a Blazor app or planning to do so soon, this should help clear up a lot of confusion. Let me know what you think, and feel free to reply if you have any questions. Take care, Patrick...