TextBoxFor Helper retains previous value even when model value is empty

前端 未结 3 956
北恋
北恋 2021-01-11 16:54

I have an MVC form for adding a simple entity. I am using TextBoxFor(model => model.FieldName) to create the input fields. I have a Save button and a Save and New button.

3条回答
  •  温柔的废话
    2021-01-11 17:39

    I would suggest using

    ModelState.Clear();
    

    instead of

    ViewData = null;
    

    since I find that much more clear what you are trying to do. Although both will accomplish what you're trying to do.

提交回复
热议问题