It's quite difficult to get blocks to post back to themselves as they are partial controllers but there's some old guidance here https://world.optimizely.com/blogs/team-oshyn/dates/2016/3/posting-forms-with-episerver-mvc/ although it's pre .NET core depending on the version you are using. You can get pages to do fairly simple with it such as https://krompaco.nu/2015/01/working-with-your-own-forms-in-episerver-and-mvc/
However my suggestion that's the easiest would just be to handle in via a Web API and some JS instead and have your form post to an API without reloading the page. It's a more modern and cleaner way anyhow. Such as https://dev.to/amjadmh73/submit-html-forms-to-json-apis-easily-137l
I'd appreciate it if anyone had any tips for this.
I have created a simple block for purposes of calculation, using information entered in the block data in the Optimizely CMS edit mode. The idea is that the user enters their information, the calculator form submits on click and the viewmodel is updated with the results of the calculation.
The problem is that while this works:
This doesn't:
The methods are in the same controller, and the latter one returns ONLY the partial view to the page instead of it embedded on the site like when calling the index. I realize this is because of how the CMS calls these controllers to render blocks/pages etc.
What should I do to have my method update the model for that partial view in place and not return ONLY the updated partial view to the browser?