在设计模式中隐藏用户控件

发布于 2024-08-11 23:50:11 字数 128 浏览 1 评论 0原文

我的 ASP.Net (3.5) 页面中的控件用于模拟弹出窗口 (Visual-Studio 2008)。 问题在于,在设计模式下,所有这些弹出窗口都位于页面中的正常控件之上。

所以我的问题是:如何在设计模式中隐藏用户控件。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泪眸﹌ 2024-08-18 23:50:11

如果您使用用户控件,您可以利用设计器忽略您的代码的事实。我进行了以下操作:

在您的用户控件中创建两种样式:

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

在您的用户控件中创建两个 asp 面板:

<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>

将其添加到您的代码中:

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

        base.OnPreRender(e);
    }

对我来说,这会创建在设计器中为我的用户呈现一小段文本的预期效果控制

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

成熟稳重的好男人 2024-08-18 23:50:11

通过谷歌搜索了一下,我认为你不能使用 ascx 。我认为如果您需要的话,您应该将其变成自定义控件。

http://www.west-wind.com/WebLog/posts/189。 aspx 可能有助于

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

如果您创建自定义控件,它保存用户控件的实例,并使用上面链接的方法来隐藏其所有内容。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文