Register.cshtml - Set the newsletter field to true and hidden from view CustomerController.cs - No changes apart from extra code to view ModelState errors
Stepping through the code on Register page load, the correct fields are being enabled and I can see the Countries (1) and Counties (101) on the model.
Once I fill in the form and then click register, all the fields (i.e City enabled / Company enabled) which were set to True on page load, are now set to False. The AvailableCountries and AvailableCounties are also 0, which is where the ModelState fails on first.
I've attached the screenshot here: http://www.protechsales.co.uk/capture.jpg
I am getting the same issue when using the Create User in the admin section.
It's hard to say where the issue is without debugging
redmorello wrote:
Once I fill in the form and then click register, all the fields (i.e City enabled / Company enabled) which were set to True on page load, are now set to False. The AvailableCountries and AvailableCounties are also 0, which is where the ModelState fails on first.
They should be set to "False". If you want to persist values between requests, then store them in hidden inputs. This is how MVC works. The AvailableCountries and AvailableCounties should not contain any items after postback (these values are repopulated after each postback if no redirection is done)