I have a form. in that form I have a text area property.once I click submit button I want to show some view bag values in same page, while I'm clearing the form.
In my scenario everything getting clear except one text area. so for that
I have used following approach
Model Class
public class SomeModel
{
...
public list<user> userlist {get; set}
}
Controller Class
[HttpPost]
public ActionResult SomeAction(SomeModel model)
{
model.userlist = new List<user>();
if (ModelState.IsValid)
{
.....
ModelState.Clear();
ModelState.Remove(model.SampleTextArea);
model.SampleTextArea = ""
}
return View("SomeAction", model);
}
now everything working fine for the first time. but without page refreshing If I fill same values to this form and click submit,
since its saying model validation invalid this is function not working from 2nd attempt onward for same model values.
its saying error as "userlist" System.Int[32] getting null
how can I clear this text area value properly,without page directing(RedirecToAction())