设置自定义控件属性

3 c# asp.net user-controls

我虽然很简单,但我今天无法得到它.

我有一个用户控件,其中包含一个网格控件.

public Unit Width
{
    get
    {
        return CustomerGrid.Width;
    }
    set
    {
        CustomerGrid.Width = value;

    }
}
Run Code Online (Sandbox Code Playgroud)

我公开了width属性,当我在设计器中设置它时,它在运行时工作但不是设计时.

我将继承什么类或重写方法以使我的控件在设计时运行.

注意我试图从WebControl继承但得到了消息

Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class 
Run Code Online (Sandbox Code Playgroud)

Cla*_*edi 5

我知道你在谈论用户控件(ascx)而不是自定义控件(没有ascx).如果是这种情况,您应该从UserControl继承,并且您可以在设计时使用该属性而无需任何其他添加.

如果你对自定义控件有所了解,那么你有一篇关于为自定义控件添加设计时支持的好文章

http://msdn.microsoft.com/en-us/library/aa478960.aspx