Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!!!

like image 756
user1030181 Avatar asked Nov 10 '11 19:11

user1030181


1 Answers

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

like image 133
Dismissile Avatar answered Oct 20 '22 08:10

Dismissile