【问题标题】:How to find if ASP.net server control is loaded in DESIGN mode or not?如何查找 ASP.net 服务器控件是否以 DESIGN 模式加载?
【发布时间】:2014-03-02 10:05:51
【问题描述】:

我的 ASP.net 服务器控件给了我错误:“错误渲染控件”。下面是截图。

运行时它按预期工作,但在设计时我遇到了错误。

【问题讨论】:

标签: c# asp.net web-controls


【解决方案1】:

这里我写了一个小函数来判断控件是加载在设计视图还是运行时。因此我们可以决定是否使用HTTPContext。

public bool IsInDesignMode()
    {
        if (HttpContext.Current == null)
            return true;
        else
            return false;
    }

-- 谢谢 迪帕克·雷

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-03
    • 2011-12-19
    • 1970-01-01
    • 1970-01-01
    • 2015-08-08
    • 1970-01-01
    • 2012-07-12
    相关资源
    最近更新 更多