Reputation: 4833
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
Reputation: 11
You also might check out
Note that it's in the System.Web.Mvc namespace--
http://msdn.microsoft.com/en-us/library/system.web.mvc.hiddeninputattribute.aspx
Upvotes: 1
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
Reputation:
How about using DisplayAttribute.AutoGenerateField? You could set that to false when you want to not autogen UI for that property.
Upvotes: 5