PM's Blog

Pramod Mohanan's notes about ASP.NET, MVC, C#, SQL, jQuery, Bootstrap

Disallow Model to retain its state in MVC 3

By default when a page is posted back in MVC3 it retains the form values. so on redisplay of the same page, we find the values are retained.

In case this need to be disallowed the following can be used so the model does not retain its state.

   ModelState.Clear();

It can also be used to remove just one of the key value pairs from the ModelState like

   ModelState.Remove("KeyName");

Leave a Reply

Your email address will not be published. Required fields are marked *

PM's Blog © 2018