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, I just released a new video showing a better way to use GitHub Copilot in real .NET projects. Watch it here š If you ever felt like Copilot starts strong but then your code slowly turns into chaos, youāre not alone. It happens to most developers when they start using AI without giving it the right guidance. In the video, I show you one simple file you can add to your project that keeps your code clean, structured, and consistent. No guessing. No random patterns. Just a clear...
Hey friend, I just published a new video that walks you through how to upgrade to .NET 10. Watch it here š If you're already trying the update, you may have seen this: the app builds no errors but⦠Blazor doesn't load That happened in my project too. And the fix is small, but easy to miss. In the video, I show: how to update the target frameworks how to update NuGet packages what changed for Blazor and how to fix the missing static assets issue No hype. Just a clear step-by-step walkthrough....
Hey friend, I just released a new video that shows how to add AI to a .NET app. Watch it here š In the video, I take a simple .NET project and make it smart with AI. The app can generate item backstories with one click. Like magic. No big setup. No overthinking. Just .NET, Copilot, and the OpenAI API working together. If youāve ever wondered: How do I call the OpenAI API from a .NET app? Can Copilot help with real features? How do I make my app do more than CRUD? This will help. Give it a...