How to hide the inner controls of a UserControl in the Designer?

前端 未结 3 955
心在旅途
心在旅途 2020-12-22 11:13

I have a UserControl that contains a DropDownList and an ObjectDataSource. That control is used in the markup of my MasterPage.

In the Designer of a ContentPage that

相关标签:
3条回答
  • 2020-12-22 11:27

    I'm guessing that the control you refer to, ComponentArt:Grid, have an associated ControlDesigner which can do about anything, including designtime editable areas and custom action menus (the menu associated with the arrow in the upper right corner).

    However, Visual Studio does not [last time I tried] execute the control designer for UserControls, so you can not easily control this. There's a lot of magic happening in the background in the UserControlDesigner including parsing the html code. However, I've never seen actual compilation of the codebehind file, where the ControlDesigner attribute would be specified.

    You will need to rewrite your control as a server control for Visual Studio to check for the attribute, and allowing your custom designtime view.

    0 讨论(0)
  • 2020-12-22 11:27

    Visual studio doesn't support this. The moment you specify the word "user control", the thing goes beserk and renders everything you put on it.

    Fortunately you can influence how server controls are rendered. In other words, you can cheat the Visual Studio designer by making use of that. The code you need can be found here: http://www.codeproject.com/Tips/773145/Hiding-contents-in-ASP-Net-user-control-designer

    0 讨论(0)
  • 2020-12-22 11:31

    I'm not very familiar with WebForms but the BrowsableAttribute might be what you are looking for. Also look at the DesignTimeVisibleAttribute.

    The System.ComponentModel namespace has a number of other attributes that may do what you need.

    0 讨论(0)
提交回复
热议问题