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 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...
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...
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