How to hide property of custom ASP.NET control on aspx page?

I am writing an ASP.NET user control and I want it to have several properties that should only be visible from the code at runtime - I mean that these properties should not be visible either in the designer or in the designer The aspx code for the page containing this control. I tried using the following attributes:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false)]
public List<Item> SomeData { ... }

but unfortunately this property still appears in the Intellisense combo box when editing an aspx page. Is it possible to hide this property everywhere except server code?

+7
properties
source share
2 answers

This should do the trick:

 //Hide from Designer Property Grid [Browsable(false)] // Hide from VS.NET Code Editor IntelliSense [EditorBrowsable(EditorBrowsableState.Never)] // Not Serialized in Designer Source code "HTML view" [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public List<Item> SomeData { ... } 
+12
source share

Amiir's answer definitely works, but I would like to add that sometimes even after applying the attributes, Intellisense still displays the properties. This is the result of Visual Studio caching Intellisense files. If you create the same project on another computer, it will not show properties. If this really bothers you, you can clear the cache by deleting all files in the folder "C: \ Documents and Settings \ [YOUR_USER_NAME] \ Application Data \ Microsoft \ VisualStudio \ 10.0 \ ReflectedSchemas."

+2
source share

All Articles