下面我们就来编写一个简单的Component,打开vs 2005添加一个新的ClassLibrary工程,名称为Components,更改Class1的代码如下:using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;namespace Components
{
public class Component1 : Component
{
private int _id;
private string _name;
private DateTime _createDateTime; // 在Property窗口中为灰色显示。
public int Id
{
get { return _id; }
} // 在Property窗口中可以设置值。
public string name
{
get { return _name; }
set { _name = value; }
} // 在Property窗口中不可见。
public DateTime CreateDateTime
{
set { _createDateTime = value; }
}
}
}生成后,我又新建了一个Web项目,然后引用了生成的组件,并且在工具箱中新建的卡,把那组件给引用了,那个组件出现在工具箱中,可是是灰色的,用不了不知道为什么希望高手给说说,我哪作错了,我是VS2008
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;namespace Components
{
public class Component1 : Component
{
private int _id;
private string _name;
private DateTime _createDateTime; // 在Property窗口中为灰色显示。
public int Id
{
get { return _id; }
} // 在Property窗口中可以设置值。
public string name
{
get { return _name; }
set { _name = value; }
} // 在Property窗口中不可见。
public DateTime CreateDateTime
{
set { _createDateTime = value; }
}
}
}生成后,我又新建了一个Web项目,然后引用了生成的组件,并且在工具箱中新建的卡,把那组件给引用了,那个组件出现在工具箱中,可是是灰色的,用不了不知道为什么希望高手给说说,我哪作错了,我是VS2008
文章在这里,说是最基础的了
using System.Collections.Generic;
using System.Text;
using System.ComponentModel;namespace Components
{
public class Atest : Component
{
private int _id;
private string _name;
private DateTime _createDateTime; // 在Property窗口中为灰色显示。
public int Id
{
get { return _id; }
set { _id = value; }
} // 在Property窗口中可以设置值。
public string name
{
get { return _name; }
set { _name = value; }
} // 在Property窗口中不可见。
public DateTime CreateDateTime
{
get { return _createDateTime; }
set { _createDateTime = value; }
}
}
}
我改成这样的了,也没用哦
屬性頁
建置
目標framework
设的是.net framework 3.5 输出类型是 类库
看了你就会发现是用在winform里的
这是在开发自定义 ASP.NET 服务器控件时作为派生源的主要类。Control 没有任何针对用户界面 (UI) 的功能。如果创作没有 UI 的控件或者组合其他呈现它们自己的 UI 的控件,则从 Control 派生。如果创作具有 UI 的控件,则从 WebControl 或 System.Web.UI.WebControls 命名空间中的任何控件派生,该命名空间为自定义控件提供适当的起点。
楼主的被灰色掉, 应该是 rootdesigner 对工具栏设置了 ToolboxItemFilter 方面的属性
System.ComponentModel.Component这个是开发组件用的。难道组件是在WinForm中用的?不对哦?WebFomr中也有组件哦?哪位明白给讲讲哦
庖丁解牛-Asp.net 3.5控件和组件开发技术中也只看到讲控件部分,难道控件==组件?希望高手给讲讲哦
Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)
[ThemeableAttribute(false)]
[BindableAttribute(true)]
public class Control : IComponent, IDisposable, IParserAccessor,
IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor
它作为 web 体系下, 单独实现了 IComponent 接口, 可以认为是 web 体系下的 Component.
我想还是跟设计时有关, winform/webform 需要截然不同的两个设计时架构.
呵呵,本来在Web上开发组件的就不多,至少我就没怎么见过,大部分人都是开发控件的
毕竟c/s与b/s还是不一样的
我觉得Web不支持组件拖放,最大的原因就是,Web上的元素都是用标签来表示的,而这些元素都是继承自System.Web.UI.Control或System.Web.UI.WebControls.WebControl,他们通过Render事件可以在html中生成相应的html标签,如果是Component,估计做不到这一点吧
SqlDataSource一类的控件也没有Render出标签哦,这真的很难理解,微软就是不起平道
public class Control : IComponent, 呢