Reputation: 51
I have a domain model in a DLL that I want to keep separate from my main ASP.NET MVC project.
I want to decorate the properties in this model with metadata attributes (such as DisplayName, UIHint, DataType, etc.). This is so that I can call EditorForModel to have these properties properly rendered in my ASP.NET MVC View.
Most of the attributes are available in the namespace System.ComponentModel.DataAnnotations but to my surprise, [HiddenInput] is NOT part of this namespace. It seems that [HiddenInput] is only in System.Web.Mvc (which I cannot reference from my stand-alone domain model DLL).
My domain model is in its own separate DLL class, and I don't want to move it inside my ASP.NET MVC project.
What other solutions do I have if I want to flag certain attributes in this model as "hidden" so that EditorForModel can recognize it (and hide it) when rendering the view?
Upvotes: 0
Views: 658
Reputation: 7172
You could try the UiHintAttribute that resides in the DataAnnotations namespace
[UIHint("Hidden")]
public int ID { get; set; }
HTH
Upvotes: 1