Jason Thompson
Jason Thompson

Reputation: 4833

Any sort of "Hidden" attribute in System.ComponentModel.DataAnnotations?

I'm trying to write a dynamic control in Microsoft MVC that lets me edit the entity in a grid (specifically using jqgrid). Well, I build my columns and colmodels in my controller based on the entity I'm trying to modify. I'd like to have a way to mark a column as a hidden column, but I'd like to not just create arbitrary Attributes if a standard one already exists. So I'm looking through System.ComponentModel.DataAnnotations which has a lot of good things in it, but not what I'm looking for. Does such an attribute exist? Thanks!

Upvotes: 7

Views: 10132

Answers (3)

realMarkusSchmidt
realMarkusSchmidt

Reputation: 4320

I just stumbled across this and couldn't use the suggested solution because I don't have .NET 4 available for this project.

So ended up using the EditorBrowsableAttribute, which also controls e. g. the visibility of properties in the Visual Studio Designer and IntelliSense:

http://msdn.microsoft.com/en-us/library/8a045wyx(v=VS.80).aspx

It's available since .NET 1.0.

Upvotes: 1

user1228
user1228

Reputation:

How about using DisplayAttribute.AutoGenerateField? You could set that to false when you want to not autogen UI for that property.

Upvotes: 5

Related Questions