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

拟墨画扇 提交于 2020-01-12 14:03:14

问题


What is Exaclty ScaffoldColumn(false) and HiddenInput(DisplayValue = false)?

And What are the main difference between these two ? Which one is best to use??

Thanks!!!


回答1:


[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.



来源:https://stackoverflow.com/questions/8085003/hiddeninputdisplayvalue-false-vs-scaffoldcolumnfalse

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