开发者

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

I'm writing ASP.NET custom control, and I want it to have a few properties which should be visible only from code behind during run-time - I mean, these properties should not be visible both in a designer and in a aspx code of page containing this control. I've tried to use following attributes:

[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]

[Browsable(false)]

public List<Item> SomeData { ...开发者_Go百科 }

but unfortunately this property is still visible in an Intellisense combobox when editing aspx page. Is it possible to hide this property everywhere besides server-side code ?


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 { ... }


Amiir's answer definitely works, but I'd like to add that sometimes even after applying the attributes, the Intellisense still displays the properties. This is a result of Visual Studio caching the Intellisense files. If you build the same project on a different machine, it will not show the properties. If this really bugs 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."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜