HiddenInput(DisplayValue = false)] vs [ScaffoldColumn(false)]

人走茶凉 提交于 2019-12-04 02:20:34

[ScaffoldColumn(false)] tells Visual Studio not to scaffold the column when generating a template for your view. When you create a new view, you can create a strongly typed view. When you do that Visual Studio asks you what template to use (Create, Edit, List, etc). If you create an Edit/Create template; for example, if you put [ScaffoldColumn(false)] on your model property then it just won't generate a DisplayFor() or EditorFor() call in the template, so it won't be included in your view.

[HiddenInput] will tell the DisplayFor/EditorFor methods that it should create a hidden html field for that value. When you post to a form, it will be included in the values but it will be "hidden" from the view when people look at it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!