开发者

Hide User-Control in Design Mode

Controls in my ASP.Net (3.5) pages to simulate popups (Visual-Studio 2008). The problem is that all these popups are positioned over the normal controls in the page in design mode.

So my Question is:开发者_运维百科 How can I hide User-Controls in Design-Mode.


If you are using a usercontrol you can take advantage of the fact the designer ignores your code. I got the following to work:

create two styles in your user control:

<style type="text/css">
    .hide
    {
        display:none;
    }
     .show
    {
        display:;
    }
</style>

create two asp panels in your usercontrol:

<asp:Panel ID="pnlDesigner" runat="server" CssClass="show">
Put content you want to show in designer here
</asp:Panel>
<asp:Panel ID="pnlDisplay" runat="server" CssClass="hide">
Put all your actual content here
</asp:Panel>

add this to your code:

 protected override void OnPreRender(EventArgs e)
    {
        pnlDisplay.CssClass = "show";
        pnlDesigner.CssClass = "hide";

        base.OnPreRender(e);
    }

For me this creates the desired effect of having a small block of text render in the designer for my user control


From googling around a bit I don't think you can with an ascx. I think you should turn it into a custom control if you need this.

http://www.west-wind.com/WebLog/posts/189.aspx might help

edit: http://ajdotnet.wordpress.com/2006/08/28/do-you-value-design-time-support/

you might be able to do this if you create a custom control that holds an instance of your user control, and uses the method linked to above to hide all its content.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜