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, .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
Hey Reader, If youāve been coding for a while, youāve probably asked yourself this too: āAm I getting better⦠or just older?ā Iāve been writing software for fifteen years now, and that question still sneaks up on me. But looking back, Iāve realized something: real growth in tech isnāt about frameworks or chasing trends. Itās about staying curious, patient, and keeping your spark alive when everything feels heavy. So I made a new video about it, my 15 biggest lessons from 15 years of coding....
Hey Reader, If youāre a Blazor developer, you know that annoying flash when your app loads data during pre-rendering. Itās been around forever. Sure, you could disable pre-rendering, but then you'd hurt performance and SEO. Well⦠with .NET 10, we finally have a real fix: the new Persistent State Attribute. š š„ Watch my full tutorial about it here: In this video, I walk you through: ā What causes the flashing issue ā Why disabling pre-rendering isnāt ideal ā How the new Persistent State...