Best way to create a Form in MVC (aspnet 6)


Question: How do you create a form that is pesists data on ModelState validation?

Login to See the Rest of the Answer

Answer:
When designing a form it is very important to remember that it can be a key to having a painless data entry to your application. 

Good Practices when dessigning a form
1. Make sure that your form remembers data entered into fields when model is invalid.
    - This is very important as it allows users to only correct the mistakes on the form and not to enter all the fields again.
2. Send clear message on what is needed to be done in order for the form to be valid.
     - Do not show confusing messages or text to the user, as this may cause frustrations to the end user.

How to persist data to the form in MVC AspNet 5 Razor View
1. Create the form with input fields
2. Let the form submit to a function/Action marked for HTTPPost verb
3. Check if the Model is valid by using the code below
   if(!ModelState.IsValid){
 ModelState.Clear();//This is important as you would want to return the very model with current data so that 
//the user doesn't have to enter data twice.
   return View(model);
}







For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email AddressContact: [email protected]